1
0

Closed ebt channel with a defer; bazinga!

This commit is contained in:
Stephen M. McQuay 2012-09-03 21:53:00 -06:00
parent eca42e2e55
commit 75b8de26b0

View File

@ -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