On Thursday, 27 August 2020 11:39:11 UTC+2, targe...@gmail.com wrote:
>
> To me, if `x == nil` and then `y != nil` after `y = x` is much more 
> confusing.
>

This can happen only if x and y have different  types.
And for different types this is pretty normal as you can have
    x == 0.2   //  true
    y = int(x)
    float64(y) != 0.2  // true too
With the only difference that you have explicit type conversions
where interface assignment is implicit.

And this is not even the strangest thing that can happen:
NaN floats are especially peculiar. You can have
   x := y
   x != y  // true
   x != x  // also true
 
That is something everybody has to learn once. It is a
property of all float types. Different types behave differently.
And this is true not only for operators like +, - or / but also
for operators like =, == and !=.

For the rest of the argument: It _really_ isn't  an actual
problem. In 10 years of Go this happened maybe three
time to me and was dead simple to identify.

V.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1ad000eb-05ef-473b-b8f2-379df14ca155o%40googlegroups.com.

Reply via email to