Range (String) Question

Hi All,

I am newbie on Ruby. I got a (newbie’s) question on my study:

(‘a’…‘zz’).to_a
we got [‘a’, … ‘z’, ‘aa’ … etc till … ‘zz’ ]

It seems the sequence is like ‘a’, ‘b’, …‘z’, ‘aa’, … ‘zz’

Now if I want an Range object contents like:
‘a’, ‘b’, …‘z’, 'aa’
If I write like:
(‘a’…‘aa’).to_a # Ooops, I got only [‘a’]
that is because: ‘a’.next == ‘b’ which > ‘aa’

This is a little bit strange for me, in one side, we saw the real sequence
(‘a’ to ‘zz’), but if we try take a sub sequence (‘a’ …‘aa’) from it, it fail…

Is this normal? (BTW: sub sequence of an integer interval do not have this problem)
If my understanding is correct, that is because ‘a’.next > ‘aa’;
how can you construct an Range (‘a’, ‘b’, …‘z’, ‘aa’) in the simplest way?

Thanks.

···

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

No, I think this is a bug. I’ve made a patch (-> Attachement) that
hopefully fixes it.

ruby-string.patch (842 Bytes)

···

On 2003-06-23 07:20:13 +0900, D T wrote:

Is this normal?


The problems of business administration in general and data base
management in particular are much too difficult for people that think in
IBMerese, compounded with sloppy English.
– Edsger Dijkstra, How do we tell truths that might hurt?

[…]

Sorry. Perhaps this patch is better to guard against infinite loops
without throwing exceptions.

ruby-string.patch (779 Bytes)

···

On 2003-06-23 07:20:13 +0900, D T wrote:


Were it left to me to decide whether we should have government without
newspapers or newspapers without government, I should not hesitate for a
moment to prefer the latter. But I should mean that every man should
receive those papers and be capable of reading them.
– Thomas Jefferson