go的多个返回值。。。

package main

import "fmt"

func Sendtchan(c ...int) <-chan int {
out := make(chan int)
go func() {
for i := range c { //c is Sclic type
out <- c[i]

}
close(out)

}()
return out

}

func Recchin(in <-chan int) <- chan int{
out:=make(chan int)
go func() {
for n:= range in{
out <- n
}
close(out)
}()
return out

}
func Testslinc(c ...interface{}) []interface{}{
for i:=range c{
fmt.Println(i)
}
return c
}
func main() {
v:=[]int{7,8,9}

c:=Sendtchan(v...) //c:=Sendtchan(7,8,9)
our:=Recchin(c)
for i:=range our{
fmt.Println(i)
}



}

//

7
8
9





上一篇:流程控制语句


下一篇:java运算符