On this note, while more specific to the option case, also worth knowing about Array.filterMap
and Array.keepSome
Array.filterMap([1, 3, 5, 7], n => n > 4 ? Some(n) : None)
// [5, 7]
Array.keepSome([Some("a"), None, Some("b")])
// ["a", "b"]
On this note, while more specific to the option case, also worth knowing about Array.filterMap
and Array.keepSome
Array.filterMap([1, 3, 5, 7], n => n > 4 ? Some(n) : None)
// [5, 7]
Array.keepSome([Some("a"), None, Some("b")])
// ["a", "b"]