From: Jamis Buck Date: 2004-02-18T12:15:44+09:00 Subject: Re: boolean to int conversion 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 > Besides adding them yourself, I don't think so. However, you can use the ternary operator to good effect here: a = true puts( a ? 1 : 0 ) a = false puts( a ? 1 : 0 ) -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/blog/jamis.cgi ruby -h | ruby -e 'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a << r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'