I have this piece of code now:
results
|> List.filter(Belt.Option.isSome)
|> List.map(item =>
switch (item) {
| Some(item) => item
}
)
Can anyone make it shorter? It is a filter that removes the non-valid values followed by a map that converts/unwraps the optional values to just values.
In Scala it would just be flatten
:
scala> List(Some("test"),None,None,Some("foo"),Some("bar"),None).flatten
res4: List[String] = List(test, foo, bar)