August 2021
Beginner
112 pages
1h 23m
English
| Puzzle 21 | A Double Take |
| | package main |
| | |
| | import ( |
| | "fmt" |
| | ) |
| | |
| | func init() { |
| | fmt.Printf("A ") |
| | } |
| | |
| | func init() { |
| | fmt.Print("B ") |
| | } |
| | |
| | func main() { |
| | fmt.Println() |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: A B
Normally, the Go compiler will not let you define two functions with the same name in the same package. However, init is special. Here’s what the ...
Read now
Unlock full access