Local Variables
While the main variables needed within a loop are usually declared implicitly in for
clauses, sometimes you’ll need auxiliary variables, which you can declare with with
clauses.
with var [ = value-form ]
The name var becomes the name of a local variable that will cease to exist when the loop finishes. If the with
clause contains an =
value-form
part, the variable will be initialized, before the first iteration of the loop, to the value of value-form.
Multiple with
clauses can appear in a loop; each clause is evaluated independently in the order it appears and the value is assigned before proceeding to the next clause, allowing later variables to depend on the value of already declared variables. Mutually independent variables can be declared in one with
clause with an and
between each declaration.