August 2021
Beginner
112 pages
1h 23m
English
| Puzzle 23 | Who’s Next? |
| | package main |
| | |
| | import ( |
| | "fmt" |
| | ) |
| | |
| | var ( |
| | id = nextID() |
| | ) |
| | |
| | func nextID() int { |
| | id++ |
| | return id |
| | } |
| | |
| | func main() { |
| | fmt.Println(id) |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will not compile.
Building the code shows the problem:
| | $ go build next_id.go |
| | # command-line-arguments |
| | ./next_id.go:8:2: initialization loop: |
| | /home/miki/Projects/go-brain-teasers/code/next_id.go:8:2: ... |
Read now
Unlock full access