Casting to a String

suggest change
123.5.to_s    #=> "123.5"
String(123.5) #=> "123.5"

Usually, String() will just call #to_s.

Methods Kernel#sprintf and String#% behave similar to C:

sprintf("%s", 123.5) #=> "123.5"
"%s" % 123.5 #=> "123.5"
"%d" % 123.5 #=> "123"
"%.2f" % 123.5 #=> "123.50"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents