Permalink
Browse files

Document Integer#even? and #odd? edge cases: zero and negative numbers.

  • Loading branch information...
henrik committed May 23, 2008
1 parent 88ef718 commit 8072ebcacc642cc0e7937e61051b9fe05507f037
Showing with 8 additions and 4 deletions.
  1. +8 −4 activesupport/lib/active_support/core_ext/integer/even_odd.rb
@@ -3,10 +3,14 @@ module CoreExtensions #:nodoc:
module Integer #:nodoc:
# For checking if a fixnum is even or odd.
#
- # 1.even? # => false
- # 1.odd? # => true
- # 2.even? # => true
- # 2.odd? # => false
+ # 2.even? # => true
+ # 2.odd? # => false
+ # 1.even? # => false
+ # 1.odd? # => true
+ # 0.even? # => true
+ # 0.odd? # => false
+ # -1.even? # => false
+ # -1.odd? # => true
module EvenOdd
def multiple_of?(number)
self % number == 0

0 comments on commit 8072ebc

Please sign in to comment.