I was reading through confident ruby and I was trying out how to define a reusable proc. From the examples given, I wrote this:
DEFAULT_BLOCK = -> { 'block executed' }
answers = {}
answers.fetch(:x, &DEFAULT_BLOCK)
I was expecting it to return block executed
since x
is not found in the Hash but instead it returned wrong number of arguments (given 1, expected 0) (ArgumentError)
. What could the problem be? I haven't given the block an argument.