From: ara.t.howard@... Date: 2006-10-12T04:00:44+09:00 Subject: Re: Compact if statement for Codegolf On Thu, 12 Oct 2006, Joel VanderWerf wrote: > ara.t.howard@noaa.gov wrote: >> On Thu, 12 Oct 2006 dblack@wobblini.net wrote: >> >>> Hi -- >>> >>> On Thu, 12 Oct 2006, Drew Olson wrote: >>> >>>> I'm working on my codegolfing skills and was wondering, what is the >>>> shortest possible way to write the following in ruby: >>>> >>>> if a==0 >>>> 1 >>>> else >>>> 2 >>>> end >>> >>> The smallest I can think of is: >>> >>> a==0?1:2 >>> >> >> if a will only have values 0 or 1 you could use >> >> 2**a > > In that case: > > a+1 touche techer, touche. -a -- my religion is very simple. my religion is kindness. -- the dalai lama