Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 8072ebcacc642cc0e7937e61051b9fe05507f037 1 parent 88ef718
Henrik Nyh authored May 23, 2008
12  activesupport/lib/active_support/core_ext/integer/even_odd.rb
@@ -3,10 +3,14 @@ module CoreExtensions #:nodoc:
3 3
     module Integer #:nodoc:
4 4
       # For checking if a fixnum is even or odd.
5 5
       #
6  
-      #   1.even? # => false
7  
-      #   1.odd?  # => true
8  
-      #   2.even? # => true
9  
-      #   2.odd?  # => false
  6
+      #   2.even?  # => true
  7
+      #   2.odd?   # => false
  8
+      #   1.even?  # => false
  9
+      #   1.odd?   # => true
  10
+      #   0.even?  # => true
  11
+      #   0.odd?   # => false
  12
+      #   -1.even? # => false
  13
+      #   -1.odd?  # => true
10 14
       module EvenOdd
11 15
         def multiple_of?(number)
12 16
           self % number == 0

0 notes on commit 8072ebc

Please sign in to comment.
Something went wrong with that request. Please try again.