Ruby - Blocks, Procs, and Lambdas
Which Ruby code snippet correctly determines if a block was passed to a method?
block_given? is a method and must be called with parentheses or as a method call.block_given? correctly. if yield; puts "Block present"; end incorrectly uses yield as a condition. if block_given; puts "Block present"; end misses the question mark. if block; puts "Block present"; end uses an undefined variable block.block_given? with question mark [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions