Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "log"
- )
- func num() func() int {
- n := -1
- return func() int {
- n += 1
- return n
- }
- }
- func main() {
- f := num()
- if !(f() == 0) {
- log.Fatal("Wrong number")
- }
- if !(f() == 1) {
- log.Fatal("Wrong number")
- }
- if !(f() == 2) {
- log.Fatal("Wrong number")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement