For checking if a fixnum is even or odd.
- 1.even? # => false
- 1.odd? # => true
- 2.even? # => true
- 2.odd? # => false
Methods
Public Instance methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb, line 10
10: def even?
11: self % 2 == 0
12: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb, line 14
14: def odd?
15: !even?
16: end