Meshtastic-Apple/Meshtastic/Extensions/Array.swift
Garth Vander Houwen 3273a59ce2 Fix map line crash
2023-04-27 18:01:23 -07:00

18 lines
337 B
Swift

//
// Array.swift
// Meshtastic
//
// Created by Garth Vander Houwen on 4/27/23.
//
import Foundation
extension Array {
func mapNonNils<T, E>(_ transform: (E) -> T) -> [T] where Element == Optional<E> {
return self.compactMap { element in
guard let element = element else { return nil }
return transform(element)
}
}
}