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
on 2007-01-03 12:15
on 2007-01-03 12:31
If string contains a number in String form, let's say '123', then: Integer(string) #=> 123 -Chris
on 2007-01-03 13:46
On Jan 3, 2007, at 3:15 AM, Prashant Jadhav 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 Mornini, CTO -- Engine Yard, Ruby on Rails Hosting -- Reliability, Ease of Use, Scalability -- (866) 518-YARD (9273)
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.