Issue #14697 has been updated by marcandre (Marc-Andre Lafortune).


I am not convinced that `step` is used enough to justify this. I know I basically never use it. Here's the number of uses for some projects:
  rails: 3 uses
  bundler: 0 uses
  sinatra: 0 uses
  WikiEduDashboard: 0 uses (a typical Rails app: https://github.com/WikiEducationFoundation/WikiEduDashboard )

When thinking about this, I am able to see the relation between "modulo" and "step", but it wasn't immediately obvious at all.

In summary: my opinion is that it is not worth the cognitive load.


----------------------------------------
Feature #14697: Introducing Range#% as an alias to Range#step
https://bugs.ruby-lang.org/issues/14697#change-71566

* Author: mrkn (Kenta Murata)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
In #13904, `Enumerator::ArithmeticSequence` has been accepted for the representation of a range with step value.
And in #12912, a new syntax of endless range `(1..)` has been accepted.

Combining these new features, we can write an endless step range like `(1..).step(2)` in Ruby 2.6.
It can be used for array slicing like python's `1::2`.

If `Range#%` is introduced as an alias to `Range#step`, we can write a step range like `(1..)%2`.
This notation is already introduced numo-narray.




-- 
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>