by ashton314 · 3y ago · 0 comments
UPDATE: I misread the article. This isn’t what happens. My bad.
Honestly, I feel like Go focuses so much on superficial simplicity that you wind up with bad/leaky abstractions all over the place as well as bad primitive obsession.
/rant
No, you've misunderstood it.
The iterator function gets a yield function which can be called with a value (the value to be yielded). The yield function returns a boolean indicating whether the process should continue or terminate.
func SomeIterator(yield func(bool) bool) bool {
for whatever {
if !yield(a_calculated_boolean_value) {
return false
}
}
return true
}
There, yielding boolean values without incident.