Calculate the number of digits in an integer.
1.length #=> 1 10.length #=> 2 100.length #=> 3
CREDIT: Victor H. Goff III
Is bitmask set?
7.bitmask?(7) #=> true 7.bitmask?(5) #=> true 8.bitmask?(3) #=> false
CREDIT: George Moschovitis
Returns true if this integer is even, false otherwise.
2.even? #=> true 3.even? #=> false
CREDIT: Daniel Schierbeck
Returns true if this integer is odd, false otherwise.
2.odd? #=> false 3.odd? #=> true -99.odd? # -> true -98.odd? # -> false
CREDIT: Daniel Schierbeck
Like times but returns a collection of the yield results.
a = 3.of { |i| "#{i+1}" } a => [ "1", "2", "3" ]