3 ms·
> Now I can't have an iterator that returns Booleans. No, you've misunderstood it. The iterator function gets a yield function which can be called with a valu
by Jtsummers 3y ago
> Now I can't have an iterator that returns Booleans.
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.