tags:

views:

280

answers:

3

I have an array:

int_array = [11,12]

I need to convert it into

str_array = ['11','12']

I'm new to this technology

+2  A: 
str_array = int_array.map(&:to_s)
dasil003
i'm still getting the output as [11, 12].. i didnt help
How are you checking the type of your output?
srboisvert
This works in Rails because it adds Symbol#to_proc
dylanfm
+5  A: 
str_array = int_array.collect{|i| i.to_s}
nuriaion
didnt help .. :(
This worked fine for me.
srboisvert
its working fine for me too.. thank you
+1  A: 

Start up irb

irb(main):001:0> int_array = [11,12]
=> [11, 12]
irb(main):002:0> str_array = int_array.collect{|i| i.to_s}
=> ["11", "12"]

Your problem is probably somewhere else. Perhaps a scope confusion?

srboisvert