Closed ebt channel with a defer; bazinga!
This commit is contained in:
parent
eca42e2e55
commit
75b8de26b0
@ -9,6 +9,7 @@ import (
|
||||
func Walk(t *tree.Tree, ch chan int) {
|
||||
// do it as a nested closure so that I can control the call to close so
|
||||
// that I can use the range-based forloop in main.main
|
||||
defer close(ch)
|
||||
var walk func(t *tree.Tree)
|
||||
walk = func(t *tree.Tree) {
|
||||
if t != nil {
|
||||
@ -18,7 +19,6 @@ func Walk(t *tree.Tree, ch chan int) {
|
||||
}
|
||||
}
|
||||
walk(t)
|
||||
close(ch)
|
||||
}
|
||||
|
||||
// Same determines whether the trees
|
||||
|
Loading…
Reference in New Issue
Block a user