Skip to content

Instance Method

mapEachCompact(_:)

Calls a closure, which returns an Optional, on each element in the sequence that is wrapped by an EventLoopFuture.
func mapEachCompact<Result>(_ transform: @escaping (Value.Element) -> Result?) -> EventLoopFuture<[Result]>

Parameters

transform

The closure that each element in the sequence is passed into.

Return Value

A new EventLoopFuture that wraps the sequence of transformed elements.

Discussion

let collection = eventLoop.future(["one", "2", "3", "4", "five", "^", "7"])
let times2 = collection.mapEachCompact { int in
    return Int(int)
}
// times2: EventLoopFuture([2, 3, 4, 7])

See Also

EventLoopFuture