Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created June 11, 2019 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/87544a2f1de1a692862e2ecbebf2aff2 to your computer and use it in GitHub Desktop.
Save fitomad/87544a2f1de1a692862e2ecbebf2aff2 to your computer and use it in GitHub Desktop.
/// Al llamar a esta función se dejan de
/// producir las llamadas al resto de código
/// que hubieras tras la llamada a esta función
func neverEndingFunction() -> Never
{
fatalError("No voy a devolver el control")
}
/// Como llamamos a una función que devuelve `Never`
/// no hace falta que pongamos `return` al final del
/// bucle `guard`
func neverEnds(_ ending: Bool) -> String
{
guard !ending else
{
neverEndingFunction()
}
return "Continuamos como si nada..."
}
// MARK: - Test -
neverEnds(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment