[bug][fix] range of single value gets divide-by-zero exception
Peter van Rooijen
peter at vanrooijen.com
Sun Nov 14 17:22:42 PST 2004
Tim Olson wrote:
> (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:
I wonder if the bug is in the fact that a division is done at all in
such a Range, rather than in using 0 for the stepping value.
Favoring 1 over -1 seems arbitrary in any case.
Cheers,
Peter
> 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