True would become False. False would become True... Human sacrifice,
dogs and cats living together - mass hysteria!
···
On 1/21/06, dblack@wobblini.net <dblack@wobblini.net> wrote:
Hi --
On Sun, 22 Jan 2006, Dirk Meijer wrote:
> hi all,
> what do you think of these methods:
>
> class TrueClass
> def switch
> false
> end
> end
>
> class FalseClass
> def switch
> true
> end
> end
>
> i think i could find some real use for this, though switch! would probably
> be even more useful..
I think here is where a Symbol would be most fitting
light_switch = :off
light_switch = :on if dark?
E
···
On 2006.01.22 04:31, Dirk Meijer wrote:
> er, the global value 'true' is the only instance of TrueClass. so,
> doing true.switch! would make true become false?
>
> So then,
> if 1 == 1
> puts "hi"
> end
>
> Wouldn't print anything?
that, on second thought, probably wouldn't work, and the following would
have to be used:
light_switch=false
light_switch=light_switch.switch if dark==true
I'd just like to point out that this now makes it 4 Ruby programmers needed to change a lightbulb (or at least turn it on) so far in this thread. Would anybody like to take a guess at how many it would have taken in other languages?
···
On 21 Jan 2006, at 19:42, Eero Saynatkari wrote:
I think here is where a Symbol would be most fitting