1
User
Recs.
Recs.
2
Updates
Last
Updated
Updated
Activity
5 Options
This example shows how assigning a nil/null variable into a interface results in a non nil value
func main() {
var a interface{}
var b *string
//make sure both a and b are nil
if a != nil || b != nil {
return
}
//assign one nil variable to another
a = b
//but after assigning a variable containing nil to a, a is no longer nil
if a == nil {
return
}
fmt.Printf("a != nil but a == %v", a)
//this program prints "a != nil but a == <nil>"
}
Specs
Specs are quantitative aspects of the option such as the price
Pros
Know any positive aspects of this option?
Cons
Know any negative aspects of this option?
Recommendations
Boxing/Interface surprise
Recommended 10 years ago
acidzombie24 hasn’t added their experience, pros or cons to their recommendation.