Ruby - Blocks, Procs, and Lambdas
How can you modify this method to safely call
yield only if a block is given?
def safe_call yield end
yield only if a block is given?
def safe_call yield end
block_given? to check if a block was passed.yield only if block_given? prevents errors when no block is given.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions