Is there any built in way to require that a block be passed to a Ruby method? I realize I can just raise an exception if block_given? is false, but is there some nicer way to do it?
Is there any built in way to require that a block be passed to
Share
Simply by using
yield.If you include
yieldin a method, and a block is not given, it throws an error.Put this in a file and run it:
It will throw an error like this: