Closed
Description
go version go1.6 linux/amd64
m := map[float64]int{math.NaN(): 3, math.NaN(): 4, .1: 5}
fmt.Println(m)
prints map[0.1:5 NaN:<nil> NaN:<nil>]
.
I would have hoped for map[0.1:5 NaN:3 NaN:4]
since for example iterating over the map with a for
loop can retrieve the values 3 and 4. Perhaps acceptable would be map[0.1:5 NaN:0 NaN:0]
, consistent with v, ok := m[math.NaN()]
returning 0, false. But printing when nil is not a valid value for the int type is unexpected.