From 43d43fb639cab71c9c4a465a4841da21aca52edb Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Tue, 3 Apr 2018 19:34:45 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Replace=20deprecated=20flatMap?= =?UTF-8?q?=20with=20compactMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value --- App/Commands/Install.swift | 2 +- App/Commands/Lucky.swift | 2 +- App/Commands/Upgrade.swift | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/App/Commands/Install.swift b/App/Commands/Install.swift index 5d3591e..5532532 100644 --- a/App/Commands/Install.swift +++ b/App/Commands/Install.swift @@ -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 diff --git a/App/Commands/Lucky.swift b/App/Commands/Lucky.swift index b2bc314..c139019 100644 --- a/App/Commands/Lucky.swift +++ b/App/Commands/Lucky.swift @@ -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 diff --git a/App/Commands/Upgrade.swift b/App/Commands/Upgrade.swift index 7c3693d..7507043 100644 --- a/App/Commands/Upgrade.swift +++ b/App/Commands/Upgrade.swift @@ -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) }