diff --git a/Sources/KamaalExtensions/Sequence.swift b/Sources/KamaalExtensions/Sequence.swift index 06c8808..7aa2b0b 100644 --- a/Sources/KamaalExtensions/Sequence.swift +++ b/Sources/KamaalExtensions/Sequence.swift @@ -99,6 +99,12 @@ extension Sequence { try first(where: predicate) } + /// Unpacks items in the sequence to only contain non optional values. + /// - Returns: An array without optionals. + public func unpacked() -> [T] where Element == T? { + compactMap { $0 } + } + /// Group results in to a tuple of successes and failures. /// - Returns: A tuple of successes and failures. public func grouped() -> (