From: Chris Pine Date: 2003-01-04T02:09:11+09:00 Subject: Re: How to call overridden methods (finally!) ----- Original Message ----- From: "ts" pigeon% cat b.rb #!./ruby a = Numeric.instance_method(:to_int) b = Method.instance_method(:call).bind(a) b.call pigeon% pigeon% b.rb /b.rb:4:in `call': you cannot call unbound method; bind first (TypeError) from ./b.rb:4:in `call' from ./b.rb:4 pigeon% Guy Decoux ---------------------------- Thanks, Guy! You're a lifesaver. :) So this seems more like an argument *for* allowing this into the standard interpreter. Currently the above code raises the following exception instead: $ ./test.rb ./test.rb:13:in `bind': bind argument must be an instance of Method (TypeError) from ./test.rb:13 Which I think is a less helpful exception. Is the problem that it is wrong to `call' something which is a kind_of Method, but not a Method instance? Or is the problem that `a' is an UnboundMethod? Still, in the vase majority of cases, calling an overridden parent method doesn't raise an exception at all... it just does what you want it to do. I think that in every case you can achieve the same results by using `super' in clever ways, but it is messy and requires a lot of aliasing. Why not allow us to do the same thing more cleanly? Chris