From: Pit Capitain Date: 2005-02-22T23:02:03+09:00 Subject: Re: destructive! operations Caio Tiago Oliveira schrieb: > Pit Capitain, 21/2/2005 17:04: > >> ES schrieb: >> >>> Wouldn't it be possible to override the TrueClass, NilClass >>> and FalseClass methods to yield the correct behaviour for >>> this object? I'm assuming 'if something' expands to >>> 'if something == true' or something like that? >> >> >> >> If you look at the Ruby source code (this is 1.8.2), in eval.c: > > It shouldn't be in C. Such things should be in Ruby. Where do you draw the line between core functionality implemented in something like C and add-ons implemented in Ruby? > I don't know C, so I can't learn Ruby? > So can't I know the behaviours of my changes? Of course you can. The behavior of "if" is documented here, for example: http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html#UH I quoted the corresponding source code only to show that there seems to be no way to implement an "eating nil" in pure Ruby. Regards, Pit