mirror of
https://github.com/samber/lo.git
synced 2026-04-22 15:37:14 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
27 lines
482 B
Markdown
27 lines
482 B
Markdown
---
|
|
name: Drain
|
|
slug: drain
|
|
sourceRef: it/seq.go#L26
|
|
category: it
|
|
subCategory: sequence
|
|
signatures:
|
|
- "func Drain[T any](collection iter.Seq[T])"
|
|
playUrl: https://go.dev/play/p/xU_GCG861r1
|
|
variantHelpers: []
|
|
similarHelpers: []
|
|
position: 170
|
|
---
|
|
|
|
Drain consumes an entire sequence.
|
|
|
|
```go
|
|
collection := func(yield func(int) bool) {
|
|
yield(1)
|
|
yield(2)
|
|
yield(3)
|
|
fmt.Println("yielding")
|
|
}
|
|
|
|
it.Drain(collection)
|
|
// prints "yielding" three times, sequence is consumed
|
|
``` |