Исходники и презентации
This commit is contained in:
19
lessons/channels/is_closed_1/main.go
Normal file
19
lessons/channels/is_closed_1/main.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func IsClosed(ch chan int) bool {
|
||||
select {
|
||||
case <-ch:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
ch := make(chan int)
|
||||
fmt.Println(IsClosed(ch))
|
||||
close(ch)
|
||||
fmt.Println(IsClosed(ch))
|
||||
}
|
||||
Reference in New Issue
Block a user