Back to Lo

It Fromseqptr

docs/data/it-fromseqptr.md

1.53.0399 B
Original Source

FromSeqPtr returns a sequence with the pointer values. Returns a zero value in case of a nil pointer element.

go
one := 1
two := 2
var three *int = nil

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

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