34,333
edits
Changes
→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 form 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 method named ''to_f'' that can be used to retrieve the integer stored in a variable as a floating point value:
<pre>