From: Vikrant Chaudhary on 14 May 2010 05:37 Hi, If I do - ('A'..'Z').include?('AA') It returns "true", while ('A'..'Z').to_a.include?('AA') (of course) returns "false". Is it intentional or possibly a bug? I'm using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] on Ubuntu 10.04 x64
From: MrZombie on 15 May 2010 09:24 On 2010-05-14 05:37:37 -0400, Vikrant Chaudhary said: > Is it intentional or possibly a bug? > I'm using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] on > Ubuntu 10.04 x64 Mac OS X Snow Leopard running Ruby 1.9.1, same behavior. I notice that it returns false if no element of the string is included in the range. For example, given r = ('A'..'Z'): r.include?('RUBY') # returns true and: r.include?('Ruby') # also true but: r.include?('ruby') # is false. -- Thank you for your brain. -MrZombie
From: Vikrant Chaudhary on 17 May 2010 07:53 On May 14, 2:37 pm, Vikrant Chaudhary <nas...(a)gmail.com> wrote: > Hi, > If I do - > > ('A'..'Z').include?('AA') > > It returns "true", while > > ('A'..'Z').to_a.include?('AA') > > (of course) returns "false". Is it intentional or possibly a bug? > I'm using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] on > Ubuntu 10.04 x64 Probably because the way Strings are compared, "AA" < "Z" #=> true
From: MrZombie on 17 May 2010 10:39 On 2010-05-17 07:53:34 -0400, Vikrant Chaudhary said: > On May 14, 2:37�pm, Vikrant Chaudhary <nas...(a)gmail.com> wrote: >> Hi, >> If I do - >> >> ('A'..'Z').include?('AA') >> >> It returns "true", while >> >> ('A'..'Z').to_a.include?('AA') >> >> (of course) returns "false". Is it intentional or possibly a bug? >> I'm using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] on >> Ubuntu 10.04 x64 > > Probably because the way Strings are compared, "AA" < "Z" #=> true Just for the kicks, I tried with ('a'..'z').include? 'aa' Guess what? False. -- Thank you for your brain. -MrZombie
From: Michael W Ryder on 17 May 2010 14:51 Vikrant Chaudhary wrote: > Hi, > If I do - > > ('A'..'Z').include?('AA') > > It returns "true", while > > ('A'..'Z').to_a.include?('AA') > > (of course) returns "false". Is it intentional or possibly a bug? > I'm using ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] on > Ubuntu 10.04 x64 Using ruby 1.9.1 and Windows Vista both examples return false.
|
Pages: 1 Prev: How to Pump $1,000s in CASH & Checks to your door. Next: difference between $0 and __FILE__ |