Loops/Foreach: Difference between revisions

Content added Content deleted
m (→‎{{header|LFE}}: Updated to more recent syntax)
Line 1,692: Line 1,692:
=={{header|Swift}}==
=={{header|Swift}}==
<lang swift>for i in [1,2,3] {
<lang swift>for i in [1,2,3] {
println(i)
print(i)
}</lang>
This works for any type that conforms to the <code>SequenceType</code> protocol (including arrays, collections, generators, ranges).

Alternately:
{{works with|Swift|2.x+}}
<lang swift>[1,2,3].forEach {
print($0)
}</lang>
}</lang>
This works for any type that conforms to the <code>Sequence</code> protocol (including arrays, collections, generators, ranges, and strings).


=={{header|SystemVerilog}}==
=={{header|SystemVerilog}}==