Ruby - Blocks, Procs, and Lambdas
Identify the error in this Ruby method:
def show
yield if block_given
end
show { puts "Hello!" }def show
yield if block_given
end
show { puts "Hello!" }block_given? requires the question mark and should be called as block_given? or block_given?(). Here it is missing the question mark.yield is correctly used and does not require arguments here. The method does not require parameters to accept a block.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions