Ad
  • Default User Avatar

    Yep, it's unnecessary. But they make the code more clear to view. :)

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Thanks for the feedback. Floats compeletly slipped my mind in this scenario. Nice catch!

  • Default User Avatar

    I really like your use of the unless structure here, and I really like that you are making sure that the values are numbers. One thing that I encountered as I was working on this kata is that class Integer only includes whole numbers, such as 3, 17, 293, but not floats, such as 3.0, 17.4, and 293.3333. It is the same issue if with Fixnum. I found that I needed to use Numeric to ensure that I was able to check all sorts of numbers for validity. Example:

    3.is_a(Integer) => true
    (3.0).is_a(Integer) => false
    (3.0).is_a(Fixnum) => false
    (3.0).is_a(Numeric) => true
    (3.3).is_a(Numeric) => true
    3.is_a(Numeric) => true