"Evan Webb" <evan / fallingsnow.net> schrieb im Newsbeitrag
news:1077074531.9643.4.camel / maxwell...
> A few different ways:
>
> 1)
>    v = value ? 1 : 0
>
>    where value is either true or false

In fact "value" might be anything with "false" and "nil" meaning "false"
(and evaluating to "0" in this case) and everything else meaning "true"
(yields "1").

Regards

    robert


> 2)
>
>   class TrueClass; def to_i; 1; end; end
>   class FalseClass; def to_i; 0; end; end
>
>
>
> Evan Webb // evan / fallingsnow.net
>
> On Tue, 2004-02-17 at 19:09, Cere Davis wrote:
> > I'm a bit of a Ruby newbie so be kind pls.
> >
> > Could someone tell me if there's an easy way to make a value of True
go to 1 and False goto 0?
> >
> > a sort of to_i method?
> >
> > Thanks,
> > Cere
> >
> >
> >
>
>
>