From: Vikrant Chaudhary on
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
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
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
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
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.