How do I return a true or false from a function and then check it. This code returns an error: mismatched types func() bool and bool
func d() bool {
var e bool
return e
}
if d == true {
fmt.Printf("true")
}
How do I return a true or false from a function and then check it. This code returns an error: mismatched types func() bool and bool
func d() bool {
var e bool
return e
}
if d == true {
fmt.Printf("true")
}
You're comparing the actual function to true, not the function result, you need to call the function, e.g.
func d() bool {
var e bool
return e
}
if d() {
fmt.Printf("true")
}