Class Integer
In: lib/facet/float/round_at.rb
lib/facet/float/round_to.rb
lib/facet/numeric/succ.rb
lib/facet/integer/odd%3F.rb
lib/facet/integer/times_collect.rb
lib/facet/integer/fact.rb
lib/facet/integer/factorial.rb
lib/facet/integer/even%3F.rb
Parent: Object

Methods

External Aliases

factorial -> fact
  Common alias for factorial.
  require 'facet/integer/factorial'

  2.fact  #=> 2
  3.fact  #=> 6
  4.fact  #=> 24

Public Instance methods

Is an integer even?

  require 'facet/integer/even&odd'

  2.even?  #=> true
  3.even?  #=> false

Calculate the factorial of an integer.

  require 'facet/integer/factorial'

  2.factorial  #=> 2
  3.factorial  #=> 6
  3.factorial  #=> 24

Is an integer odd?

  require 'facet/integer/even&odd'

  2.odd?  #=> false
  3.odd?  #=> true

To properly support Float’s rounding methods, Integer must also be augmented.

To properly support Float’s rounding methods, Integer must also be augmented.

Like times but returns a collection of the yield results.

  require 'facet/integer/times_collect'

  a = 3.times_collect { |i| "#{i+1}" }
  a => [ "1", "2", "3" ]

[Validate]