[Pharo-users] Interval form: x to: y when x > y - or how to count down...
konrad.hinsen at fastmail.net
Fri Feb 22 11:13:12 EST 2019
On 22/02/2019 15:57, Tim Mackinnon wrote:
> I've just been caught out with Intervals - why can't you do:
> 5 to: 1 do: [ :i | Transcript show: i printString] (eg a negative interval)?
> if you want to iterate down a series of numbers do you really have to do:
> 5 to: 1 by: -1 do: […
> I always assumed that if x > y the step was automatically -1 (but its not).
Expectations are obviously personal, but as far as I am concerned, I'd
expect to see the behavior that Pharo implements. If you don't specify
by:, you get a default value of 1. That's much simpler than a default
value depending on the bounds of the interval.
More information about the Pharo-users