blob: d49c752ab19393ae5332b543f6997b2eb1cdb5ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// anonymous functions3
// Make me compile!
// I AM NOT DONE
package main
import "fmt"
func updateStatus() func() string {
var index int
orderStatus := map[int]string{
1: "TO DO",
2: "DOING",
3: "DONE",
}
return func() string {
index++
return "What should I return?"
}
}
func main() {
anonymous_func := updateStatus()
var status string
status = anonymous_func()
status = anonymous_func()
if status == "DONE" {
fmt.Println("Good Job!")
} else {
panic("To complete the challenge the status must be DONE")
}
}
|