Issue #15919 has been updated by shevegen (Robert A. Heiler).


It took me a moment to understand the proposal (I am not sure why I am having a hard time understanding
proposals lately; but in my defence, I am getting older, and it is currently very hot in central europe -
hope you folks have a better time with the weather).

So to the proposal - actually I sort of agree with sawa that there may be use cases for it. Or at the
least I can imagine that this may be the case.

I also think that Matthew's comment makes sense; people can misread "5 times 3" as "5 x 3" (I deliberately
omitted the () and . there.

How about some hash-parameter instead? Like:


    5.times(start_at: 3){|i| p i}

Or some other parameter, perhaps just start: or something like that.

Although I should also point out that this would be different to what sawa suggested, so since
it is his proposal, the focus should be on his initial suggestion primarily, not the deviation;
I was just trying to integrate what Matthew commented on.

I am fine either way and I am fine with the current behaviour, too - I really am neutral mostly
in regards to this issue. :)

----------------------------------------
Feature #15919: Offset parameter for `Integer#times`
https://bugs.ruby-lang.org/issues/15919#change-78539

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I request an optional argument on `Integer#times` to set the offset at start, just like `Enumerator#with_index`.

```ruby
5.times(3){|i| p i}
# >> 3
# >> 4
# >> 5
# >> 6
# >> 7
```

I think there are plenty of use cases, especially when the offset is 1.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>