Class | Integer |
In: |
numeric.c
lib/rational.rb |
Parent: | Numeric |
As int is already an Integer, all these methods simply return the receiver.
Returns a string containing the ASCII character represented by the receiver’s value.
65.chr #=> "A" ?a.chr #=> "a" 230.chr #=> "\346"
Iterates block, passing decreasing values from int down to and including limit.
5.downto(1) { |n| print n, ".. " } print " Liftoff!\n"
produces:
5.. 4.. 3.. 2.. 1.. Liftoff!
As int is already an Integer, all these methods simply return the receiver.
Returns the greatest common denominator of the two numbers (self and n).
Examples:
72.gcd 168 # -> 24 19.gcd 36 # -> 1
The result is positive, no matter the sign of the arguments.
Returns the lowest common multiple (LCM) of the two arguments (self and other).
Examples:
6.lcm 7 # -> 42 6.lcm 9 # -> 18
Returns the Integer equal to int + 1.
1.next #=> 2 (-1).next #=> 0
In an integer, the value is the numerator of its rational equivalent. Therefore, this method returns self.
As int is already an Integer, all these methods simply return the receiver.
Returns the Integer equal to int + 1.
1.next #=> 2 (-1).next #=> 0
Iterates block int times, passing in values from zero to int - 1.
5.times do |i| print i, " " end
produces:
0 1 2 3 4
As int is already an Integer, all these methods simply return the receiver.
As int is already an Integer, all these methods simply return the receiver.
As int is already an Integer, all these methods simply return the receiver.