Last active
November 6, 2018 02:53
-
-
Save dmlebron/f4ce893f32b934dfc75c383f0abc659f to your computer and use it in GitHub Desktop.
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
enum Animal: String { | |
case unknown | |
case dog | |
case cat | |
} | |
extension Optional where Wrapped == Animal { | |
var unwrappedOrUnknown: Animal { | |
switch self { | |
case .some(let unwrapped): | |
return unwrapped | |
case .none: | |
return .unknown | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment