Back to Lo

It Fromseqptror

docs/data/it-fromseqptror.md

1.53.0343 B
Original Source

FromSeqPtrOr returns a sequence with the pointer values or the fallback value.

go
one := 1
var two *int = nil

collection := func(yield func(*int) bool) {
    yield(&one)
    yield(two)
}

values := it.FromSeqPtrOr(collection, 99)
var result []int
for val := range values {
    result = append(result, val)
}
// result contains [1, 99]