Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created June 11, 2019 08:15
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/7998fe803d1d1109bf914303f7be8d46 to your computer and use it in GitHub Desktop.
Save fitomad/7998fe803d1d1109bf914303f7be8d46 to your computer and use it in GitHub Desktop.
/// Una función normal y corriente.
/// No devuelve nada
func returningFunction() -> Void
{
print("returningFunction()")
}
/// Una función normal y corriente.
/// Devuelve una cadena de texto
func returningFunction(withParameter name: String) -> String
{
return ("returningFunction(withParameter: \(name))")
}
/// 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")
}
// MARK: - Test -
returningFunction()
let text = returningFunction(withParameter: "Parametro")
print(text)
neverEndingFunction()
// Esto no se va a llamar nunca...
returningFunction()
let otherText = returningFunction(withParameter: "Parametro número 2")
print(otherText)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment