Last active
July 19, 2018 16:27
-
-
Save pushkarnk/a9f88723e81d4d605ec7b017f75e355c to your computer and use it in GitHub Desktop.
This is a cool way to replace `x == nil` checks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Optional { | |
var isNil: Bool { | |
switch self { | |
case .none: return true | |
case .some: return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment