Ruby:Convert a String to a Number
Revision as of 12:28, 31 December 2007 by Andr3w (New page: ==String to int== <question xmlns:htm="http://www.w3.org/1999/xhtml" lang="rb" className="Demo"><prog> s = "1234" i= s.to_i puts i+1 </prog> <p>You can use String methods <code>to_i</code>...)
String to int
You can use String methods
to convert to integers or floating point numbers.
The value "1234" is a string, you need to treat it as a number - to add 1, giving 1235.