In Ruby 1.9, instance_eval
calls the block the with receiver as the first argument:
- In Ruby 1.8,
receiver.instance_eval(&block)
callsblock.call()
- In Ruby 1.9,
receiver.instance_eval(&block)
callsblock.call(receiver)
This will blow up in your face in Ruby 1.9, where a lambda
crashes when it is called with a different number of arguments:
wrong number of arguments (1 for 0) (ArgumentError)
Forget that instance_eval
ever existed. Use instance_exec
instead, which behaves consistently across all Rubies.
Posted by Henning Koch to makandra dev (2013-03-02 08:47)