# Range (String) Question

**URL:** <https://rubytalk.org/t/range-string-question/6506>\
**Category:** ruby-talk\
**Created:** [22 June 2003 22:20 UTC](https://rubytalk.org/t/range-string-question/6506 "2003-06-22T22:20:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![D\_T1](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@D\_T1](https://rubytalk.org/u/D_T1)\
**Post date:** [22 June 2003 22:20 UTC](https://rubytalk.org/t/range-string-question/6506/1 "2003-06-22T22:20:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Florian\_Frank2](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@Florian\_Frank2](https://rubytalk.org/u/Florian_Frank2)\
**Post date:** [22 June 2003 23:17 UTC](https://rubytalk.org/t/range-string-question/6506/2 "2003-06-22T23:17:22Z")

</div>

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

[ruby-string.patch](https://rubytalk.org/uploads/short-url/nioKASgn02KWcy8FZdZjxikOkf7.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?

---

<div class="post-metadata">

**Author:** ![Florian\_Frank2](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@Florian\_Frank2](https://rubytalk.org/u/Florian_Frank2)\
**Post date:** [22 June 2003 23:26 UTC](https://rubytalk.org/t/range-string-question/6506/3 "2003-06-22T23:26:22Z")

</div>

[…]

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

[ruby-string.patch](https://rubytalk.org/uploads/short-url/15wrv2apbnQ9Jsk1BEqHEyxN3rM.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
