Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Building A Well Formed Number Handling Class From Scratch

By Peter Cooper / February 25, 2010

Over on the Ruby Best Practices blog, somenums.pngRobert Klemme walks through the process of building a new numeric class from scratch in Ruby - taking into account all the gotchas and considerations that pop up along the way. Robert's task is harder and more involved than you'd initially suspect.!

Robert chooses to build a HexNum class that can represent integers that are then displayed as hex numbers. There are considerations to be made with handling conversions from existing numeric types and his new HexNum class, conversions to other types, supporting standard comparison methods, and overloading.

All of the above concerns are covered in the post with all the quality and detail you should expect from the RBP blog by now. This post in particular should prove interesting to most Ruby developers who feel happy digging deep (no, this isn't an article for beginners!).

[job] BeenVerified.com is currently looking for a Ruby and Rails developer to join their team in New York City. Alternatively, check out one of the other 12 jobs on our Ruby jobs board!

Other Posts to Enjoy

Twitter Mentions