How to convert string into int

hi all
i got a array int by str.scan() method
just tht the numbers are stored in array in for of string

and i have to add this numbers in array

so how can i convert this number strings in integers

pls tell me a method or procedure

bbye

If string contains a number in String form, let’s say ‘123’, then:

Integer(string) #=> 123

-Chris

On Jan 3, 2007, at 3:15 AM, Prashant J. wrote:

i got a array int by str.scan() method
just tht the numbers are stored in array in for of string

and i have to add this numbers in array

so how can i convert this number strings in integers

~/Desktop: irb
irb(main):005:0> “1 2 3 4 5”.scan(/\d+/).inject(0) { |sum,item| sum
+item.to_i }
=> 15


– Tom M., CTO
– Engine Y., Ruby on Rails Hosting
– Reliability, Ease of Use, Scalability
– (866) 518-YARD (9273)