Back to the original question: use float as key for a map is very
dangerous. You will encounter a lot of subtle problems, not only NaN, but
also rounding up, approximations, etc. It is not encourage to compare two
floats for equality. While for the map, when we lookup, we are using
equality checking, which is not encouraged. So, never, ever use float as
key of a map please.
On Saturday, June 6, 2015 at 3:16:31 PM UTC-7, minux wrote:

On Sat, Jun 6, 2015 at 5:02 PM, Brad Fitzpatrick <brad...@golang.org
<javascript:>> wrote:
Seems like fmt could have a special case for float-keyed maps, ranging
over it all to get the values, and then sorting the (keys, rangeindex)*,
and using value[rangeindex].
I don't know how fmt could implement this for arbitrary maps with floating

To use range, the compiler needs to know the map's type statically.

We probably could add a range operation on reflect.Value for maps, but I
know if it will pull its own weight for such a corner case.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions



site design / logo © 2021 Grokbase