Changes

Jump to: navigation, search

Understanding Ruby Variables

2 bytes added, 21:13, 30 November 2007
Converting Variable Values
== Converting Variable Values ==
It is important to note that the above approach is a somewhat destructive way to change a variable type. Often something a little more subtle is needed. For example, we might want to read the value from a variable but convert the extracted value to a different type. The Ruby variable classes have methods that can be called to convert their value to a different type. For example, the ''Fixnum'' class has a method named ''to_f'' that can be used to retrieve the integer stored in a variable as a floating point value:
<pre>

Navigation menu