Variable declaration reset: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(K)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(One intermediate revision by one other user not shown)
Line 435:
 
But of course, there's no variables here.
 
Longhand loops can be emulated, using lambdas (in which case local variables expire when the lambda exits), but this is not what many programmers would think of as a straightforward longhand loop.
 
=={{header|Nim}}==
In Nim, a loop create a new block. Variables declared in the loop body are created and initialized at each round: they do not retain the value from one round to the next.
Line 782 ⟶ 785:
=={{header|Wren}}==
Note firstly that unassigned variables are impossible in Wren. If a variable is created without giving it an explicit value, then it is assigned the special value 'null' which is the only instance of the Null class and therefore distinct from all other values in the language.
<syntaxhighlight lang="ecmascriptwren">var s = [1, 2, 2, 3, 4, 4, 5]
 
// There is no output as 'prev' is created anew each time
9,485

edits