https://go.dev/play/p/2L3NR09zIJu
package main
import (
"fmt"
"math"
"fortio.org/sets"
)
func test(v float64) {
set := sets.New(v, v, v, v)
set.Add(v, v, v)
fmt.Printf("Using %f : %d elems %v and has: %v\n", v, len(set), set, set.Has(v))
}
func main() {
test(math.Pi)
test(math.NaN())
}
outputs
# As expected
Using 3.141593 : 1 elems 3.141592653589793 and has: true
# Not great
Using NaN : 7 elems NaN,NaN,NaN,NaN,NaN,NaN,NaN and has: false