Skip to content
instance method

Integer#times

() { (::Integer) -> void } -> self
() -> ::Enumerator[::Integer, self]
times {|i| ... } → self
times → enumerator

Calls the given block self times with each integer in (0..self-1):

Example
a = []
5.times {|i| a.push(i) } # => 5
a                        # => [0, 1, 2, 3, 4]

With no block given, returns an Enumerator.

See also #succ #to_bn #size #to_f also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0