This piece of code looks quite counter-intuitive to me:
var first *byte
var second interface{}
fmt.Println(first, first == nil) // <nil> true
fmt.Println(second, second == nil) // <nil> true
fmt.Println(first == second) // false
As far as I understand, the case is that the first variable is a pointer to an empty variable of type byte
, whereas the second is an empty interface. So, as the variables are not the same type, they are not considered equal.
But if they are not equal to each other, how can they be equal to some third value? Is it common situation in programming languages when Transitive Law is not held?