<snip> In 1.9.2, anyway, #instance_methods seems to list methods in the order
they were created/aliased, though I don't know whether this is
guaranteed:
ruby-1.9.2-p0 > class C; def x; end; alias a x; def b; end; def d; end;
alias c d; def f; end; def e; end; end
=> nil ruby-1.9.2-p0 > C.instance_methods
=> [:x, :a, :b, :d, :c, :f, :e, ... ]
David
Maybe it is best to say that somehow it really does not matter, I
would be curious to see where it matters. The following, completely
useless code, somehow demonstrates this:
Class::new do
def a; end
alias_method :x, :a
remove_method :a
alias_method :a, :x
p instance_methods( false )
end
and the question I would like to ask is, what is :a in this case? An
alias to itself after having been removed I guess ;). But I prefer
David's notation above which is the perfect explanation of what is
really happening here.(1)
Hopefully that kind of manipulation can be safely ignored when talking
about "definition order".
(1) Maybe with the exception that remove_method "really" means, remove
the entry with this name pointing to the method, but by all means let
us keep the name :).
Cheers
Robert
···
On Sat, Oct 16, 2010 at 3:19 PM, David A. Black <dblack@rubypal.com> wrote:
--
David A. Black, Senior Developer, Cyrus Innovation Inc.
The Ruby training with Black/Brown/McAnally
Compleat Stay tuned for next event!
Rubyist http://www.compleatrubyist.com
--
There are worse things than having people misunderstand your work. A
worse danger is that you will yourself misunderstand your work.
-- Paul Graham