Good example of antiquity of some Core Ruby classes

22
Sep/09
0

A common pattern in Ruby is to call .to_s on an object when you want a String, even if the object itself might be a String. So, e.g., if you are getting NoMethodErrors on nils when you need a String, you might call .to_s to convert that nil into a String (”).

Well, you might want to do the same thing to convert Floats to BigDecimals. But guess what? BigDecimal doesn’t include a .to_d method! Oops. The BigDecimal class must be so old that this idiom hadn’t evolved.

Filed under: Technology
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.