Ruby - Enumerable and Collection Processing
Which of the following is the correct syntax to use
map with a block to add 3 to each element in array [1, 2, 3]?map with a block to add 3 to each element in array [1, 2, 3]?The block must take a parameter with vertical bars: { |x| ... }.
[1, 2, 3].map { |x| x + 3 } uses correct block syntax. Others have syntax errors or missing block parameter.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions