Explain the new 'Range-over-function' iterators introduced in Go 1.23.
Last updated
Go 1.23 lets
for ... rangeloop over functions, such asiter.Seq[V](func(yield func(V) bool)) oriter.Seq2[K,V]for pairs.The iterator calls
yieldonce per element. If the loop breaks or returns,yieldreturnsfalseand the iterator should stop.This gives lazy, composable iteration over any data structure without intermediate slices. It powers the
iter,slicesandmapsiterator helpers.