diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-05 16:54:17 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-05 16:54:17 +0000 |
commit | d08271e62f4cd5b3c42f3e385d9166f6e591cbaa (patch) | |
tree | d050396a511489eb180d3b38156d1db426916508 /activesupport/lib/active_support | |
parent | 97e39fcb6418a5b1d5254ebb1059df796db21701 (diff) | |
download | rails-d08271e62f4cd5b3c42f3e385d9166f6e591cbaa.tar.gz rails-d08271e62f4cd5b3c42f3e385d9166f6e591cbaa.tar.bz2 rails-d08271e62f4cd5b3c42f3e385d9166f6e591cbaa.zip |
Added Fixnum#even? and Fixnum#odd?
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1094 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/fixnum/even_odd.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb b/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb new file mode 100644 index 0000000000..1fa6b95846 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/fixnum/even_odd.rb @@ -0,0 +1,20 @@ +module ActiveSupport #:nodoc: + module CoreExtensions #:nodoc: + module Fixnum #:nodoc: + # For checking if a fixnum is even or odd. + # * 1.even? # => false + # * 1.odd? # => true + # * 2.even? # => true + # * 2.odd? # => false + module EvenOdd + def even? + self % 2 == 0 + end + + def odd? + !even? + end + end + end + end +end |