Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Arithmetic expression and TRY_BLOCK_ERROR
On Sep 28, 10:46am, DervishD wrote:
}
} 'let variable=0' is shorter ;) I really don't know the reason,
} but I can find this kind of assignment everywhere :-/
I suspect it's simply Peter's preference to always use variables in
a consistent context, i.e., either in math expressions or out, not
some of each. A possible reason for this is future-proofing.
Suppose you have:
(( variable = 0 )) # or any other integer constant
Then later that gets changed to:
(( variable = othervariable ))
If you had instead written it without the (( )), the meaning of:
variable=othervariable
is entirely different.
Also, some people prefer the readability of being able to put spaces
around the "=".
However, doing integer/float assignments in math context is marginally
more efficient than doing them as plain assignments. In a single
command this is probably offset by the overhead of parsing the (( )),
but in a loop it could become important, and if you're in the habit of
always writing the (( )) you won't forget them where they matter.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author