Iterating Over an Array with each : each « Array « Ruby






Iterating Over an Array with each



[1, 2, 3, 4].each { |x| puts x }
# 1
# 2
# 3
# 4

 








Related examples in the same category

1.Arrays and Blocks
2.Assign block value to a variable in array each method
3.each with block which has if statement
4.LocalJumpError: no block given