From: ES Date: 2005-02-22T04:43:32+09:00 Subject: Re: destructive! operations On Mon, February 21, 2005 6:07 pm, Christian Neukirchen said: > Pit Capitain writes: > >> Christian Neukirchen schrieb: >>> Unfortunately, that would make the loop turn endless, as: >>> irb(main):021:0> puts "Doesn't work as I want" if EATING_NIL >>> Doesn't work as I want >> >> DOH! Here's the test I wrote for the code: >> >> if EATING_NIL then puts("nil") else puts("not nil") end >> >> > It can't be done in Ruby-only, I think. >> >> After briefly looking at the source code, I think so too. Sorry for the >> noise. Apologies beforehand, I can't access the NG, just the ML, so I don't know if these have already been covered. 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? > No problem, the idea and implementation is correct. I think I'd be partial to calling the method #not_nil? instead; mainly because it's shorter :) some_object.not_nil?.do_something >> Regards, >> Pit > -- > Christian Neukirchen http://chneukirchen.org E