array=["1","3","4"] How do i convert this array to sessionarraydb_array=[1,3,4,] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
array.map(&:to_i) Walter On Jul 18, 2012, at 10:55 AM, deal bitte wrote:> array=["1","3","4"] > How do i convert this array to > sessionarraydb_array=[1,3,4,] > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
try- array=["1","3","4"] On Wed, Jul 18, 2012 at 8:25 PM, deal bitte <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> array=["1","3","4"] > How do i convert this array to > sessionarraydb_array=[1,3,4,] > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Regards, Himanshu Prakash (+91) 959 559 1648 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
ignore last reply and try this-
array.map!{|e| e.to_i}
On Wed, Jul 18, 2012 at 8:30 PM, Himanshu Prakash
<vision2910-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:
> try-
> array=["1","3","4"]
>
>
> On Wed, Jul 18, 2012 at 8:25 PM, deal bitte
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
>
>> array=["1","3","4"]
>> How do i convert this array to
>> sessionarraydb_array=[1,3,4,]
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> --
>> You received this message because you are subscribed to the Google
Groups
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To unsubscribe from this group, send email to
>>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> Regards,
> Himanshu Prakash
> (+91) 959 559 1648
>
>
--
Regards,
Himanshu Prakash
(+91) 959 559 1648
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
No need to do this..
array.map!{|e| e.to_i}
you can do this with the first code also with a change..
array.map!(&:to_i)
On Wednesday, July 18, 2012 7:55:46 PM UTC+5, Ruby-Forum.com User
wrote:>
> array=["1","3","4"]
> How do i convert this array to
> sessionarraydb_array=[1,3,4,]
>
> --
> Posted via http://www.ruby-forum.com/.
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/_0QzvyHLAG4J.
For more options, visit https://groups.google.com/groups/opt_out.
Here is another way to do that...
array = ["1","3","4"]
array.collect do |n|
n.to_i
end
It will return you a new integer array
[1, 3, 4]
If you want to change your array in place then just put an exclamation mark
after the method collect like this...
array.collect! do |n|
On Wednesday, July 18, 2012 7:55:46 PM UTC+5, Ruby-Forum.com User
wrote:>
> array=["1","3","4"]
> How do i convert this array to
> sessionarraydb_array=[1,3,4,]
>
> --
> Posted via http://www.ruby-forum.com/.
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/eOetZhlpifcJ.
For more options, visit https://groups.google.com/groups/opt_out.