small medium large xlarge

11 Oct 2017, 12:08
Piet Eeken (1 post)

I’m not an experienced ruby-programmer but the method_missing example from page 386 seems to behave a bit weird. If you execute the command ‘puts “#{} lives in #{obj.address} and likes #{obj.likes}”’ a second time it doesnot give the right output. Debugging it shows that the block under ‘define_method(name) do |value|’ is never executed. In this example anyway you can leave out the whole singleton-business (I mean the def and the 6 lines from ‘_singleton_class.instance_exec(name) do |name|’ to get the right output.

You must be logged in to comment