Class: Range

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/range/stepped.rb

Instance Method Summary collapse

Instance Method Details

#stepped(size = 1) ⇒ Object

Returns an array with all values starting from begin, in intervall size until end. Example:

(2..17).stepped(4) # => [2, 6, 10, 14]


8
9
10
# File 'lib/ruby/range/stepped.rb', line 8

def stepped(size=1)
	enum_for(:step, size).to_a
end