Loops/Foreach: Difference between revisions

Content added Content deleted
(Added Dyalect programming language)
Line 798: Line 798:
}</lang>
}</lang>


This code would work for any type that has a method "iter" (which returns an iterator). In fact a runtime environment silently call this method for you and creates an iterator out of an array. The code above is absolutely identical to:
This code would work for any type that has a method "iter" (returning an iterator). In fact a runtime environment silently calls this method for you here and creates an iterator out of an array. The code above is absolutely identical to:


<lang Dyalect>for i in [1,2,3].iter() {
<lang Dyalect>for i in [1,2,3].iter() {