From: itsme213@... (you CAN teach an old dog ...) Date: 2003-06-08T09:13:04+09:00 Subject: Re: What should "class ... end" and "def ... end" return? Michael Granger wrote in message news:<1A475B69-98F0-11D7-B8FE-000A959D1A74@FaerieMUD.org>... > Just FYI, for classes under 1.8.0, you can do: > > myClass = Class::new( MySuperclass ) { > def foo > puts "Foo!" > end > } > > You can then assign it to a constant if you want it to look like you > did 'class MyClass...': > > MyClass = myClass > myClass.name > # => "MyClass" > > For methods, you can use Module#define_method: > > irb(main):002:0> class Foo > irb(main):003:1> rval = define_method( :foo ) { puts "Foo!" } > irb(main):004:1> p rval > irb(main):005:1> end > # > # => nil > > Some or all of these things may work under 1.6.8 with modifications; I > don't know. Thanks for explaining the rules. But I am curious about why these work this way. a) X = 55 # assigns 55 to X; returns 55 b) class X ... end # should be consistent with a) c) def ... end # should be consistent with a) So, what is the reason why (b) does not return the class, and (c) does not return the method? [There is probably a good reason]