[bug][fix] range of single value gets divide-by-zero exception
Tim Olson
tim at io.com
Fri Nov 12 17:04:20 PST 2004
(1 to: 1).
returns a divide by zero exception because the code to set the
appropriate increment value uses the <=> message, which returns 0 when
its operands are equal. The fix is to explicitly use 1 or -1:
r@(Range traits) newFrom: start to: end
"This method implicitly defines a sensible default stepping value."
[
r newFrom: start to: end by: (start <= end ifTrue: [1] ifFalse: [-1])
].
-- Tim Olson
More information about the Slate
mailing list