🚨 Replace deprecated flatMap with compactMap

'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value
This commit is contained in:
Ben Chatelain 2018-04-03 19:34:45 -06:00
parent 9a0d2163be
commit 43d43fb639
3 changed files with 5 additions and 5 deletions

View file

@ -13,7 +13,7 @@ struct InstallCommand: CommandProtocol {
func run(_ options: Options) -> Result<(), MASError> {
// Try to download applications with given identifiers and collect results
let downloadResults = options.appIds.flatMap { (appId) -> MASError? in
let downloadResults = options.appIds.compactMap { (appId) -> MASError? in
if let product = installedApp(appId) , !options.forceInstall {
printWarning("\(product.appName) is already installed")
return nil

View file

@ -32,7 +32,7 @@ struct LuckyCommand: CommandProtocol {
fileprivate func install(_ appId: UInt64, options: Options) -> Result<(), MASError> {
// Try to download applications with given identifiers and collect results
let downloadResults = [appId].flatMap { (appId) -> MASError? in
let downloadResults = [appId].compactMap { (appId) -> MASError? in
if let product = installedApp(appId) , !options.forceInstall {
printWarning("\(product.appName) is already installed")
return nil

View file

@ -23,7 +23,7 @@ struct UpgradeCommand: CommandProtocol {
let appIds: [UInt64]
appIds = apps.flatMap {
appIds = apps.compactMap {
if let appId = UInt64($0) {
return appId
}
@ -35,7 +35,7 @@ struct UpgradeCommand: CommandProtocol {
// check each of those for updates
updates = appIds.flatMap {
updates = appIds.compactMap {
updateController?.availableUpdate(withItemIdentifier: $0)
}
@ -56,7 +56,7 @@ struct UpgradeCommand: CommandProtocol {
print("Upgrading \(updates.count) outdated application\(updates.count > 1 ? "s" : ""):")
print(updates.map({ "\($0.title) (\($0.bundleVersion))" }).joined(separator: ", "))
let updateResults = updates.flatMap {
let updateResults = updates.compactMap {
download($0.itemIdentifier.uint64Value)
}