Jump to content

Loops/Foreach: Difference between revisions

m (→‎{{header|LFE}}: Updated to more recent syntax)
Line 1,692:
=={{header|Swift}}==
<lang swift>for i in [1,2,3] {
printlnprint(i)
}</lang>
This works for any type that conforms to the <code>SequenceSequenceType</code> protocol (including arrays, collections, generators, ranges, and strings).
 
Alternately:
{{works with|Swift|2.x+}}
<lang swift>[1,2,3].forEach {
print($0)
}</lang>
This works for any type that conforms to the <code>Sequence</code> protocol (including arrays, collections, generators, ranges, and strings).
 
=={{header|SystemVerilog}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.