Re: Difference between define_method and def method; end
by Robert Dober other posts by this author
Nov 1 2006 12:33AM messages near this date
Re: Difference between define_method and def method; end
|
Re: Difference between define_method and def method; end
On 10/31/06, ara.t.howard@[...].gov <ara.t.howard@[...].gov> wrote:
>
> On Tue, 31 Oct 2006, Rune Hammersland wrote:
>
> > Hello dear Rubyists.
> >
> > It was suggested on the IRC channel that I try the ML for this problem
> ...
> >
> > While looking at how to undefine a method, I found out that there is a
> > difference in how define_method and the def ... end block works. Example
> > coming up:
>
> <snip>
>
> > # Try to redefine method and call super.
> > class Child < Parent
>
> you are not redefining the method here, you are redefining the class.
> [...]
>
Ara I am afraid that is not so :(, run this e.g.
class Parent
end
class Child < Parent
puts self.object_id
def one; puts "one" end
end
class Child < Parent
puts self.object_id
end
Child.new.one
<Ara's version of code snipped>
> harp:~ > ruby a.rb
> LOL: superclass method `lol' disabled
It does the same as OP's code, I really feel this is strange.
Rune, on philiosophical grounds, I prefer the second behavior the super
method being available again, can you elaborate on why you prefer the first?
Cheers
Robert
--
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man.
- George Bernard Shaw
Thread:
Rune Hammersland
Ara T Howard
Robert Dober
Ara T Howard
Rune Hammersland
Robert Dober
Rune Hammersland
Rune Hammersland
Timothy Goddard
|