# Counting a string

**URL:** <https://www.ruby-forum.com/t/counting-a-string/184193>\
**Category:** Ruby\
**Created:** [February 26, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/counting-a-string/184193 "2010-02-26T14:31:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benedikt\_MSSS\_ller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f07891/32.png) [@Benedikt\_MSSS\_ller](https://www.ruby-forum.com/u/Benedikt_MSSS_ller)\
**Post date:** [February 26, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/counting-a-string/184193/1 "2010-02-26T14:31:11Z")

</div>

Hi  
I want to â€žcountâ€œ a string. I don’t know, how to express it better,  
because of that I’ll try to explain it. I have a string, say ‘a’. Now  
I want to increase it, so it would be ‘b’. I increase it again, it  
would be ‘c’ and so on.  
Is there a method for this task?

---

<div class="post-metadata">

**Author:** ![Benedikt\_MSSS\_ller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f07891/32.png) [@Benedikt\_MSSS\_ller](https://www.ruby-forum.com/u/Benedikt_MSSS_ller)\
**Post date:** [February 26, 2010, 2:34pm UTC](https://www.ruby-forum.com/t/counting-a-string/184193/2 "2010-02-26T14:34:07Z")

</div>

On 02/26/2010 14:30, Benedikt MÃ¼ller wrote:

> Hi  
> I want to â€žcountâ€œ a string. I don’t know, how to express it better,  
> because of that I’ll try to explain it. I have a string, say ‘a’. Now  
> I want to increase it, so it would be ‘b’. I increase it again, it  
> would be ‘c’ and so on.  
> Is there a method for this task?

Try:

“a”.succ  
=\> “b”

Regards

---

<div class="post-metadata">

**Author:** ![Benedikt\_MSSS\_ller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f07891/32.png) [@Benedikt\_MSSS\_ller](https://www.ruby-forum.com/u/Benedikt_MSSS_ller)\
**Post date:** [February 26, 2010, 2:35pm UTC](https://www.ruby-forum.com/t/counting-a-string/184193/3 "2010-02-26T14:35:17Z")

</div>

> irb
> 
> > x=‘a’  
> > =\> “a”
> 
> > x.next!  
> > =\> “b”
> 
> > x.next!  
> > =\> “c”
> 
> > x.next!  
> > =\> “d”
> 
> > x.next!  
> > =\> “e”
> 
> > x.next!  
> > =\> “f”

---

<div class="post-metadata">

**Author:** ![Benedikt\_MSSS\_ller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f07891/32.png) [@Benedikt\_MSSS\_ller](https://www.ruby-forum.com/u/Benedikt_MSSS_ller)\
**Post date:** [February 26, 2010, 2:38pm UTC](https://www.ruby-forum.com/t/counting-a-string/184193/4 "2010-02-26T14:38:12Z")

</div>

thx  
Sorry I looked in ruby-doc in the String class but I didn’t saw it so  
I thought that isn’t in the standard lib.  
☹

---

<div class="post-metadata">

**Author:** ![Benedikt\_MSSS\_ller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f07891/32.png) [@Benedikt\_MSSS\_ller](https://www.ruby-forum.com/u/Benedikt_MSSS_ller)\
**Post date:** [February 26, 2010, 3:50pm UTC](https://www.ruby-forum.com/t/counting-a-string/184193/5 "2010-02-26T15:50:12Z")

</div>

Is there a possibility to say what chars can be in the string? I want  
to have upper chars and lower chars but i want to start with only one  
char.
