Everyone Thinks Numeric Suffixes Are Neat Right Now
And they are neat. It’s just one of those really simple changes to Ruby that walks the tightrope between being a very elegant addition and being not worth anyone’s time ever.
Supposedly unleashed at last RubyConf by the sublime and blemish-free Rich Kilmer, numeric suffixes took the form of methods to
Fixnum. Stuff like
12.hours, which returns the number of seconds in a twelve hour period, availing you of having to use the unseemly
12 * 60 * 60. You can find this syntax in the new Rails 0.9.4.
If you like this idea, then you’ll probably dig flgr’s patch to Ruby, supplied a few weeks ago on Ruby-Core, which adds numeric literal suffixes to Ruby. His patch adds
b suffixes to Ruby’s number parser.
>> 5.1b => #<BigDecimal:812a76c,'0.51E1',8(8)> >> 1f => 1.0
The ensuing thread isn’t acknowledged by Matz, but a few ideas are kicked around for adding
"10:00"pm or similiar suffixes which could make for a very friendly flavor of Ruby.
Correction: The patch was fathered by Peter Vanbroekhoven. I repeat. Peter Vanbroekhoven. Well done. Peter Vanbroekhoven.