4 ms·
nil for non-pointer types should only be assignable, not comparable.
by JulianMorrison 5y ago
nil for non-pointer types should only be assignable, not comparable.
- marcus_holmes 5y agoIt doesn't solve the problem then, because for non-pointer types we have to have multiple zero values: one for assignment and one for comparison.
- Joker_vD 5y agoTo be fair, it's not that much of a problem, and even then: "if result == _ { ... }" instead of "if result == MyPrettyStruct{} { ... }" is arguably more intent-revealing, as for "if number == _ { ... }", well, I guess the recommendation would be "just don't do that". Perhaps gofmt could even automatically replace it?