step_by on negative numbers

Hrm email reply got eaten by the discourse gods.

Personally I would expect -n steps to have a the behaviour of rev().step_by(n), or be a logic error:

  • (0..10).step_by(7) should yield: 0, 7
  • (0..10).step_by(7).rev() should yield: 7, 0
  • (0..10).rev().step_by(7) should yield: 9, 2 (this is not possible to instantiate due to blanket Rev)
  • (0..10).step_by(-7) should yield: 9, 2 (or be an error)
3 Likes