On Mon, Jun 16, 2003 at 06:30:25AM +0900, Mark Wilson wrote: > > On Sunday, June 15, 2003, at 05:09 PM, you CAN teach an old dog ... > wrote: > > >[snip] > > >And, along the way, any answers to my question (on a separate thread) > >about why > > def ... end > >returns nil, instead of some kind of method object; and > > class ... end > >returns the last expression, also instead of some kind of class > >instance. > >[snip] > > def ... end > does not return a method object because methods are not objects in Ruby > (unless wrapped in a proc object). I don't know Smalltalk, but I have > heard that this is one of the differences between Ruby and Smalltalk. > > I am interested to know what would you want to do with a method object > that was returned after > def ... end One application is sugar: private def foo # bla end > The above is a serious question. > > As to > class ... end > In my irb, the above also returns nil. I don't know the actual reason > that this design choice was made, but I assume that if the new class > needs arguments, this could be a problem and that the usual case would > be to create an object separate from the class declaration, therefore, > to turn this characteristic off would usually be required. As it is, > you can create an object of a class at any point in the program, > including immediately after the class is declared -- in other words, > turn on the behavior you want. Again, I'm curious to know why you want > this (if you do). If he wants class .. end to return the class he can always do class Foo #bla self end -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Never trust an operating system you don't have sources for. ;-) -- Unknown source