Sha256: ad3e5ae92fa47bb9ac3247091a97e141baa4c54c7f5c0c4fd85bb440f932c5a7

Contents?: true

Size: 545 Bytes

Versions: 5

Compression:

Stored size: 545 Bytes

Contents

# -*- coding: utf-8 -*-

if RUBY_VERSION < "2.4.0"

# Fixnum extensions

class Fixnum


  # @return true if the number is even
  #
  # @example
  #   2.even? => true
  #   3.even? => false
  #
  # From http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/4516

  def even?
    return self & 1 == 0
  end


  # @return true if the number is odd
  #
  # @example
  #   2.odd? => false
  #   3.odd? => true
  #
  # From http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/4516
  
  def odd?
    return self & 1 != 0
  end


end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sixarm_ruby_ramp-5.0.2 lib/sixarm_ruby_ramp/fixnum.rb
sixarm_ruby_ramp-5.0.1 lib/sixarm_ruby_ramp/fixnum.rb
sixarm_ruby_ramp-5.0.0 lib/sixarm_ruby_ramp/fixnum.rb
sixarm_ruby_ramp-4.2.7 lib/sixarm_ruby_ramp/fixnum.rb
sixarm_ruby_ramp-4.2.5 lib/sixarm_ruby_ramp/fixnum.rb