[squeak-dev] Interval indexOf:startingAt: is fuzzy

Chris Muller asqueaker at gmail.com
Sun Feb 10 19:12:34 UTC 2019


Like Rectangles, Intervals only support Integers, i.e., see Interval>>#last.


 - Chris

On Sun, Feb 10, 2019 at 8:27 AM Nicolas Cellier
<nicolas.cellier.aka.nice at gmail.com> wrote:
>
> Hi,
> does anyone really need a fuzzy Interval indexOf:startingAt: ?
> Right now, we have this:
>
>     ((0.1 to: 0.9 by: 0.1) indexOf: 0.3) = 3.
>     ((0.1 to: 0.9 by: 0.1) includes: 0.3) = true.
>
> While this can sound nice, I don't think it is.
> No other collection behaves like that.
>
>     ((0.1 to: 0.9 by: 0.1) asArray includes: 0.3) = false.
>     ((0.1 to: 0.9 by: 0.1) asSet includes: 0.3) = false.
>
> Even Interval itself does not behave consitently:
>
>     ((0.1 to: 0.9 by: 0.1) lastIndexOf: 0.3) = 0.
>     ((0.1 to: 0.9 by: 0.1) occurrencesOf: 0.3) = 0.
>     ((0.1 to: 0.9 by: 0.1) copyWithout: 0.3) = #(0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7000000000000001 0.8 0.9).
>
> We have ScaledDecimal and Fraction which are less surprising, so IMO we should better use them when we really want to play with equality rather than trying to cheat with Float equality.
>
>


More information about the Squeak-dev mailing list