all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
32
Task/Short-circuit-evaluation/Go/short-circuit-evaluation.go
Normal file
32
Task/Short-circuit-evaluation/Go/short-circuit-evaluation.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func a(v bool) bool {
|
||||
fmt.Print("a")
|
||||
return v
|
||||
}
|
||||
|
||||
func b(v bool) bool {
|
||||
fmt.Print("b")
|
||||
return v
|
||||
}
|
||||
|
||||
func test(i, j bool) {
|
||||
fmt.Printf("Testing a(%t) && b(%t)\n", i, j)
|
||||
fmt.Print("Trace: ")
|
||||
fmt.Println("\nResult:", a(i) && b(j))
|
||||
|
||||
fmt.Printf("Testing a(%t) || b(%t)\n", i, j)
|
||||
fmt.Print("Trace: ")
|
||||
fmt.Println("\nResult:", a(i) || b(j))
|
||||
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func main() {
|
||||
test(false, false)
|
||||
test(false, true)
|
||||
test(true, false)
|
||||
test(true, true)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue