`[]` method already returns `var T`. By default, you cant pass it to vars, but
can to procedures.
proc myInc(mut: var int) = mut += 1
var test = @[1, 2, 3]
test[1].myInc
Run
If you want to save ref to variable you can use "views"
{.experimental: "views".}
var test = @[1, 2, 3]
let myRef: var int = test[1]
inc myRed
echo test
Run
For your case you also can use `applyIt` from sequtils
var test = @[1, 2, 3]
test.applyIt(if it == 2: it + 1 else: it)
echo test
Run
<https://play.nim-lang.org/#ix=4FTK>
