From: Greg Weeks Date: 2007-11-11T16:40:30+09:00 Subject: bug in nested defs (?) When the following code is evaluated def foo ; "foo" ; end where does the method go? Here is what I would guess. If the evaluation context of the def is a class, then the method is an instance method of the class. If the evaluation context of the def is not a class, then the method is a singleton method of the context object. This rule is ugly, but it almost always works. What I don't understand is the one exception below. Here are the non-exceptions: class X def foo ; "foo" ; end # #method of X end X.new.foo # works obj = [] class <