Class: Range
- Inherits:
-
Object
- Object
- Range
- Defined in:
- lib/ruby/range/stepped.rb
Instance Method Summary collapse
-
#stepped(size = 1) ⇒ Object
Returns an array with all values starting from begin, in intervall size until end.
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 |