# Strange result from to\_a

**URL:** <https://www.ruby-forum.com/t/strange-result-from-to-a/165208>\
**Category:** Ruby\
**Created:** [April 10, 2009, 6:22am UTC](https://www.ruby-forum.com/t/strange-result-from-to-a/165208 "2009-04-10T06:22:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [April 10, 2009, 6:22am UTC](https://www.ruby-forum.com/t/strange-result-from-to-a/165208/1 "2009-04-10T06:22:51Z")

</div>

I had unexpected results and could not figure out why

puts (" “…”~").to\_a.inspect  
returns results of " " thru “9”

m = []  
(" “[0]…”~"[0]).to\_a.each{|c| m \<\< c.chr}  
puts m.inspect

Is a longwinded way of getting the samne but it gives all the results

" " thru “~”

Can anyone tell me why this is so?

I also hear that to\_a is to be depricated - but it is hard to figure out  
what the alternatives are. Everything I found gave the same unexpeted  
results.

Paul

---

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [April 10, 2009, 6:35am UTC](https://www.ruby-forum.com/t/strange-result-from-to-a/165208/2 "2009-04-10T06:35:19Z")

</div>

On Fri, Apr 10, 2009 at 12:22 PM, Paul Denize  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I had unexpected results and could not figure out why
> 
> puts (" “…”~").to\_a.inspect  
> returns results of " " thru “9”

works fine here, running ruby1.9

---

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [April 10, 2009, 7:20am UTC](https://www.ruby-forum.com/t/strange-result-from-to-a/165208/3 "2009-04-10T07:20:11Z")

</div>

Ok, I’m on ruby 1.8.6  
Might be time to upgrade.

Thanks

---

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [April 10, 2009, 7:31am UTC](https://www.ruby-forum.com/t/strange-result-from-to-a/165208/4 "2009-04-10T07:31:32Z")

</div>

Yep, upgraded and the problem is gone.

---

<div class="post-metadata">

**Author:** ![dangermoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@dangermoose](https://www.ruby-forum.com/u/dangermoose)\
**Post date:** [April 10, 2009, 12:57pm UTC](https://www.ruby-forum.com/t/strange-result-from-to-a/165208/5 "2009-04-10T12:57:29Z")

</div>

Paul Denize wrote:

> puts (" “…”~").to\_a.inspect  
> returns results of " " thru “9”

That’s because “9”.succ is “10” instead of “:”

> I also hear that to\_a is to be depricated - but it is hard to figure out  
> what the alternatives are.

Only Object#to\_a is deprecated.
