From: Ryan Davis Date: 2007-11-12T19:07:19+09:00 Subject: Re: bug in nested defs (?) On Nov 11, 2007, at 08:50 , Phrogz wrote: > Not a singleton method. It's just a delayed definition of a standard > instance method: > > class Bar > def def_foo > def foo > "foo" > end > end > end It actually looks pretty cool: % parse_tree_show -u # ... ^D s(:class, :Bar, nil, s(:scope, s(:defn, :def_foo, s(:args), s(:scope, s(:block, s(:defn, :foo, s(:args), s(:scope, s(:block, s(:str, "foo"))))))))) So the defn foo is just sitting inside. Whenever def_foo gets executed, the defn inside gets interpreted, defining the new foo in whatever context it is executing in.