Skip to content

Instantly share code, notes, and snippets.

@PetreVane
Last active September 29, 2019 12:19
Show Gist options
  • Save PetreVane/21ef8ea1080098e3fbaed1bc5b210c54 to your computer and use it in GitHub Desktop.
Save PetreVane/21ef8ea1080098e3fbaed1bc5b210c54 to your computer and use it in GitHub Desktop.
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