Class Integer
In: lib/extensions/numeric.rb
Parent: Object

Methods

even?   odd?  

Public Instance methods

Returns true if this integer is even, false otherwise.

  14.even?          # -> true
  15.even?          # -> false

[Source]

# File lib/extensions/numeric.rb, line 20
    def even?
      self % 2 == 0
    end

Returns true if this integer is odd, false otherwise.

  -99.odd?          # -> true
  -98.odd?          # -> false

[Source]

# File lib/extensions/numeric.rb, line 37
    def odd?
      self % 2 == 1
    end

[Validate]