Last active
September 29, 2019 12:19
-
-
Save PetreVane/21ef8ea1080098e3fbaed1bc5b210c54 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 MagicError: Error { | |
case spellFailure | |
} | |
func castSpell(_spell: String) -> Result<String, MagicError> { | |
switch _spell { | |
case "flowers": | |
return .success("Flowers falling from sky") | |
case "stars": | |
return .success("Stars lighting up your way") | |
default: | |
return .failure(MagicError.spellFailure) | |
} | |
} | |
let spell = castSpell(_spell: "stars") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment