I just tried this Google Playground recipe from Bradfritz:

https://play.golang.org/p/RYac90kI-H

(seen via https://github.com/golang/go/issues/21095)

and noted that y appears in the output but x appears as <nil>.

Can someone explain me why ? I was expecting that x appears in the same way 
like y.


package main

import (
"fmt"
"math"
)

var a, b int

func main() {
type S struct {
x int16
y float64
z interface{}
p *int
}
m := map[S]string{}
m[S{1, math.NaN(), "foo", &a}] = "x"
m[S{2, 3.0, &a, &b}] = "y"
for i := 0; i < 20; i++ {
fmt.Printf("%+v\n", m)
}
}

//output:

map[{x:2 y:3 z:0x1b5400 p:0x1b5404}:y {x:1 y:NaN z:foo p:0x1b5400}:<nil>]
map[{x:1 y:NaN z:foo p:0x1b5400}:<nil> {x:2 y:3 z:0x1b5400 p:0x1b5404}:y]



-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to