From: Richard Lionheart Date: 2004-05-19T07:20:10+09:00 Subject: Thanks to both Mark and Gabriele Hi, Thanks for your responses. Thanks especially to you, Mark, for the reference in Programming Ruby. You folks are great. Regards, Richard "Richard Lionheart" wrote in message news:4oudnTkSkNU64DfdRVn-hA@comcast.com... > Hi, > > I can't find anything in Programming Ruby to suggest why zero is treated as > true, as happens in lines and 12 in the following toy program. Is it > perhaps because Ruby has no boolean type, so zero gets converted to a > string, or something? Aside from an explantion, can you cite a relevant > page in the Thomas&Hunt book? > > Thanks in advance, > Richard > > def count_exes(l) > n = l.count "x" > end > > DATA.each_line do |line| > print line.chomp > if n = count_exes(line) then print "\t(#{n} exes in line) [Pgm line 7]" > end > if (n = count_exes(line)) > 0 then print "\t(additional note for > ex-lines)" end > puts > end > > puts "0 is " + (0?"true":"false") + " [Pgm line 12]" > > __END__ > Two 'xx's > Three 'xxx's > No ekses > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.687 / Virus Database: 448 - Release Date: 5/16/2004 > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.687 / Virus Database: 448 - Release Date: 5/16/2004