Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This code outputs:
- // 0 0 false false
- // A bug?
- // Note: now both calls to hasBlock at else branch return false, even though such result is not possible due to the if expression.
- package main
- import (
- "fmt"
- )
- func hasBlock(x, y int) bool {
- if x < 0 || x >= 1 {
- return false
- }
- return true
- }
- func main() {
- ok := false
- for x := 0; x < 1; x++ {
- for y := 0; y < 1; y++ {
- if !hasBlock(x - 1, y) {
- ok = true
- } else {
- fmt.Println(x, y, hasBlock(-1, 0), hasBlock(x - 1, y))
- }
- }
- }
- if !ok {
- fmt.Println("A bug?")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement