Ruby - Blocks, Procs, and Lambdas
Given the array
[1, 2, 3, 4], which block syntax correctly filters even numbers and returns them as a new array?[1, 2, 3, 4], which block syntax correctly filters even numbers and returns them as a new array?select filters elements for which the block returns true. The block must receive each element as a parameter.|n| and calls n.even?. [1, 2, 3, 4].select do |n| n.even? has a syntax error (missing end). [1, 2, 3, 4].select { n.even? } misses block parameters. [1, 2, 3, 4].select do n.even? end misses pipes around parameter.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions