Ryan Davis
11/12/2007 10:07:00 AM
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.