Ruby - Blocks, Procs, and Lambdas
Which of the following is the correct syntax to check if a block was given inside a Ruby method?
block_given? is a method and should be called with a question mark and optionally parentheses. The most common and clear syntax is block_given? without parentheses.yield keyword runs the block if it exists. The syntax if block_given? then yield end is correct and clear.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions