MobileCoin-Swift/Sources/Utils/CollectionSubscripts/Dictionary+KeysSubscript.swift
Kyle Fleming b4ac1178be Big bang
2021-03-15 22:58:02 -10:00

16 lines
321 B
Swift

//
// Copyright (c) 2020-2021 MobileCoin. All rights reserved.
//
import Foundation
extension Dictionary {
subscript(keys: [Key]) -> [Value]? {
let compacted = keys.compactMap { self[$0] }
guard compacted.count == keys.count else {
return nil
}
return compacted
}
}