From: D T Date: 2003-06-23T07:20:13+09:00 Subject: Range (String) Question --0-2137051609-1056320410=:61969 Content-Type: text/plain; charset=us-ascii 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! --0-2137051609-1056320410=:61969 Content-Type: text/html; charset=us-ascii
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! --0-2137051609-1056320410=:61969--