Reputation: 3
i have a value returned in json of float type like 0.0 of Float Class
this look good, but when I try to convert to string it change to "0.0"
The Console shows this :
irb(main):080:0> commission.class
=> Float
irb(main):081:0> commission.to_s
=> "0.0"
irb(main):082:0> commission.class
=> Float
irb(main):083:0> commission.class
=> Float
Can anyone help me to understand this behavior. Why class are still float?
Upvotes: 0
Views: 54
Reputation: 80065
In Ruby, the Class of an Object does not change. Ever. Some methods can result in a new object from another class. The original object does not transform or cease to exist.
Upvotes: 3