each

.each() { |element| ... }

This is for iterating over each element in the array. Each item in the array will be yielded into the attached block, in order.

names = [ 'Brian', 'Ashley', 'Graham' ]

names.each() do |name|
    // work with name here
end

.each() { |index, element| ... }

If you supply two parameters in the block, then this will supply each index along with the mapping, just like 'eachMapping'.

See also

eachIndex - eachMapping