removed all the footers; formated all the files

This commit is contained in:
Oling Cat
2012-11-01 16:10:44 +08:00
parent 77b8677ae0
commit c059171e15
73 changed files with 4576 additions and 4782 deletions

29
2.7.md
View File

@@ -115,19 +115,19 @@ channel通过操作符`<-`来接收和发送数据
)
func fibonacci(n int, c chan int) {
x, y := 1, 1
for i := 0; i < n; i++ {
c <- x
x, y = y, x + y
}
close(c)
x, y := 1, 1
for i := 0; i < n; i++ {
c <- x
x, y = y, x + y
}
close(c)
}
func main() {
c := make(chan int, 10)
go fibonacci(cap(c), c)
for i := range c {
fmt.Println(i)
fmt.Println(i)
}
}
@@ -149,13 +149,13 @@ channel通过操作符`<-`来接收和发送数据
func fibonacci(c, quit chan int) {
x, y := 1, 1
for {
select {
case c <- x:
x, y = y, x + y
case <-quit:
select {
case c <- x:
x, y = y, x + y
case <-quit:
fmt.Println("quit")
return
}
return
}
}
}
@@ -187,6 +187,3 @@ channel通过操作符`<-`来接收和发送数据
* [目录](<preface.md>)
* 上一章: [interface](<2.6.md>)
* 下一节: [总结](<2.8.md>)
## LastModified
* $Id$