# String decrement

**URL:** <https://www.ruby-forum.com/t/string-decrement/189074>\
**Category:** Ruby\
**Created:** [May 24, 2010, 1:30am UTC](https://www.ruby-forum.com/t/string-decrement/189074 "2010-05-24T01:30:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darryl\_Brown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@Darryl\_Brown](https://www.ruby-forum.com/u/Darryl_Brown)\
**Post date:** [May 24, 2010, 1:30am UTC](https://www.ruby-forum.com/t/string-decrement/189074/1 "2010-05-24T01:30:50Z")

</div>

Hello All,

It is possible to increment a string as follows:

irb(main):001:0\> x = ‘a’  
=\> “a”  
irb(main):002:0\> x.succ  
=\> “b”  
irb(main):003:0\> x.next  
=\> “b”

Is there a method to decrement a string?

Thanks,  
Darryl

---

<div class="post-metadata">

**Author:** ![Darryl\_Brown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@Darryl\_Brown](https://www.ruby-forum.com/u/Darryl_Brown)\
**Post date:** [May 24, 2010, 2:29am UTC](https://www.ruby-forum.com/t/string-decrement/189074/2 "2010-05-24T02:29:57Z")

</div>

Hi,

In message “Re: string decrement”  
on Mon, 24 May 2010 08:30:06 +0900, Darryl Brown  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|Is there a method to decrement a string?

Defining decrement behavior for strings is much more difficult than  
you might expect. Can you define exact behavior?

```
          matz.

```

---

<div class="post-metadata">

**Author:** ![Darryl\_Brown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@Darryl\_Brown](https://www.ruby-forum.com/u/Darryl_Brown)\
**Post date:** [May 24, 2010, 3:35am UTC](https://www.ruby-forum.com/t/string-decrement/189074/3 "2010-05-24T03:35:30Z")

</div>

On May 23, 8:29 pm, Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> matz.
> 
> ```

Hello Matz,

This is quite an honor.

I was facing a minor problem using ruby for some data  
collection by writing results to excel. I have since  
solved this by offsetting my start column by one cell.

This eliminates my original need to decrement the column.

Have also learned that excel cells can be expressed numerically  
as well.

Thanks,  
Darryl
