From a5227a4e9d87f381144f62ae9dc85b3604e6ee57 Mon Sep 17 00:00:00 2001 From: Pietro Caselani Date: Wed, 1 Jan 2020 22:50:45 +0100 Subject: [PATCH] Change an if-let to a guard-let --- TraktSwift/TraktDateTransformer.swift | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/TraktSwift/TraktDateTransformer.swift b/TraktSwift/TraktDateTransformer.swift index 89bcd5a4..df3be9a6 100644 --- a/TraktSwift/TraktDateTransformer.swift +++ b/TraktSwift/TraktDateTransformer.swift @@ -14,19 +14,12 @@ public struct TraktDateTransformer { } public func transformFromJSON(_ value: String?) -> Date? { - if let stringDate = value { - let resultDate = dateFormatter.date(from: stringDate) - return resultDate - } - - return nil + guard let stringDate = value else { return nil } + return dateFormatter.date(from: stringDate) } public func transformToJSON(_ value: Date?) -> String? { - if let date = value { - return dateFormatter.string(from: date) - } - - return nil + guard let date = value else { return nil } + return dateFormatter.string(from: date) } }