Foreach

foreach loop:

foreach [1,2,3] { |i|
    say i
}

for-in loop:

for i in [1,2,3] {
    say i
}

.each method:

[1,2,3].each { |i|
    say i
}

Last updated