Ruby - Blocks, Procs, and Lambdas
Identify the problem in this code snippet:
def example
yield
yield(5)
end
example { |x| puts x }def example
yield
yield(5)
end
example { |x| puts x }yield calls block with no argument, second with 5.x. The first yield passes none, but Ruby assigns nil to x, so no error occurs.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions