for it to actually return a bool. Apart from that, and that the body of the function can be a bit simplified depending on what you’re actually doing, yes. Assuming that isHere is also in package main, that is.
I’m trying to check if a user email exists on my database, so I can return a boolean and use the function like this (if isHere(“email”){// do stuffs}) in main…(guess that’s good practice)
The first time I tried it nothing happened, everything just halted with no response, so I assumed I could either not use it that way or I had some errors in my database code.
is nothing wrong to return a variable but this is a simple code and just no need. anyway, written like this, your code should work:
package main
var something bool
func isHere(email string) bool{
var status bool
status = false
if something {
status = true
}
return status
}
func main(){
something=true // TOGGLE HERE TRUE AND FALSE
if isHere("danny"){
println("say danny is here")
}else{
println("say danny is not here")
}
}