Go-zh / tour

【已弃用】新版移至 website 代码仓库
http://tour.go-zh.org
BSD 3-Clause "New" or "Revised" License
1.52k stars 223 forks source link

练习:斐波纳契闭包 案例出错 #341

Closed wiidz closed 5 years ago

wiidz commented 5 years ago

上下文: https://tour.go-zh.org/moretypes/26

请修改上方的标题来简要描述要汇报的问题,并把详细的内容写在这里,如果可能的话请附上源代码 案例中提供的代码是

package main

import "fmt"

// 返回一个“返回int的函数”
func fibonacci() func() int {
}

func main() {
    f := fibonacci()
    for i := 0; i < 10; i++ {
        fmt.Println(f())
    }
}

实际运行中

prog.go:7:1: missing return at end of function

Program exited.
OlingCat commented 5 years ago

这个练习题是让你自己补全的啊= =

Wiidz notifications@github.com 于 2019年2月8日周五 19:33写道:

上下文: https://tour.go-zh.org/moretypes/26

请修改上方的标题来简要描述要汇报的问题,并把详细的内容写在这里,如果可能的话请附上源代码 案例中提供的代码是

package main

import "fmt"

// 返回一个“返回int的函数” func fibonacci() func() int {

}

func main() {

f := fibonacci()

for i := 0; i < 10; i++ {

  fmt.Println(f())

}

}

实际运行中

prog.go:7:1: missing return at end of function

Program exited.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Go-zh/tour/issues/341, or mute the thread https://github.com/notifications/unsubscribe-auth/AA_3t0GFZ2er7GG8wVzqI4opb4sEIuoEks5vLWBtgaJpZM4avI-F .