Ad
  • Default User Avatar

    Not sure, just trained this kata. I suggested to add a testcase for this.

  • Default User Avatar

    It shouldn't!

    [1] pry(main)> def test_even(n)
    [1] pry(main)*   n % 2 == 0
    [1] pry(main)* end
    => :test_even
    [2] pry(main)> test_even(2.0)
    => true
    [3] pry(main)> 2.0 % 2
    => 0.0
    [4] pry(main)> 0.0 == 0
    => true
    

    Maybe you're thinking of .eql?:

    [5] pry(main)> 0.0.eql? 0
    => false
    

    Edit: just observed that floats should be considered uneven for this, so I eat my words! Has the kata changed since it was originally written?

  • Default User Avatar

    This would fail test_even(2.0)