-
-
Save fitomad/87544a2f1de1a692862e2ecbebf2aff2 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
/// 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