For checking if a fixnum is even or odd.
-
1.even? # => false
-
1.odd? # => true
-
2.even? # => true
-
2.odd? # => false
Methods
- E
- M
- O
Instance Public methods
Source: show
# File rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 14 def even? multiple_of? 2 end
Source: show
# File rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 10 def multiple_of?(number) self % number == 0 end
Source: show
# File rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 18 def odd? !even? end