Code Blocks and each method
x = [1, 2, 3]
x.each { |y| puts y }
# The each method accepts a single code block as a parameter.
# The code block is defined within the { and } symbols, or within do and end delimiters:
x = [1, 2, 3]
x.each do |y|
puts y
end
Related examples in the same category