It looks like you’ve already figured out a good solution, but I wanted to weigh in with something maybe obvious just because it wasn’t explicitly stated: the problem with using `=~`

and `!~`

is that they use two values (the receiver on the left side and the argument on the right), but what you want is something that uses three values (the receiver, the argument, and an epsilon). Your two links and the solution you came to (`-epsilon < x < epsilon`

) all use an epsilon, and that value should be implementation-dependent.

For example, if I’m working on values for some GIS system, I might use an epsilon of `10e-6`

for latitude and longitude, but if I want a consistent epsilon when I’m considering values in kilometers I’d want to use `10e-4`

, since both values come out to around 10 cm. Any standard library implementation of a closeness method would need to take an epsilon, which unfortunately rules out graceful use of operators like `~=`

.

I suspect you already know this, but I wanted to make sure that future readers have an explicit explanation.