From: mark sparshatt Date: 2004-11-02T06:54:06+09:00 Subject: Re: Another scrach on head Ara.T.Howard@noaa.gov wrote: > On Tue, 2 Nov 2004, mark sparshatt wrote: > >> then they'll be surprised when something like >> >> re = /./ >> if re.match("a").true? then >> puts "match" >> end >> >> never prints match > > > don't you think would suprise most newbies too? > > harp:~ > cat a.rb > re = /./ > if re.match("a") == true > puts "match" > end > > harp:~ > ruby a.rb > (nothing) > The same way when a newbie working in C is surprised when comparing against true sometimes fails. Which is why I thought the create response when seeing someone writing if a == true was to hit them round the head with a clue stick and to say, don't do that, do this if a ;-) But if we add in a true? method then it'll be harder to explain that this is the wrong thing to do. Not that I'm against the idea. I'm just pointing out a potential problem. -- Mark Sparshatt > i don't think there is anyway around that the fact that newbies must > learn that > true (in ruby) is a singleton object and that fact can bite you many > ways - and > this is not limited to only #true? > -- Mark Sparshatt