I want to know how to filter a type like array<option<t>>
into array<t>
.
The way I’ve personally tried is Belt.Array.keep((d) => d->Option.isSome))
but it doesn’t work as intended.
I want to know how to filter a type like array<option<t>>
into array<t>
.
The way I’ve personally tried is Belt.Array.keep((d) => d->Option.isSome))
but it doesn’t work as intended.
Try Belt.Array.keepMap
w/ the identity function. That API applies the function to every item and only returns the ones where the result isn’t None
.