Try to think through the following conditionals before trying them out the playgroud. Will they evaluate to true or false?
example.go
package mainimport (string">"fmt")func main() {fmt.Println(true && true)fmt.Println(true && false)fmt.Println(true || true)fmt.Println(true || false)fmt.Println(!true)}
&& will return true if both sides evaluate to true, otherwise it will return false.
|| will return true if either side evaluates to true.
! returns the opposite
Try some examples for yourself.
example.go
package mainimport (string">"fmt")func main() {fmt.Printf(string">"true && true\t %v\n", true && true)fmt.Printf(string">"true && false\t %v\n", true && false)fmt.Printf(string">"true || true\t %v\n", true || true)fmt.Printf(string">"true || false\t %v\n", true || false)fmt.Printf(string">"!true\t\t\t %v\n", !true)}