15 lines
760 B
Markdown
15 lines
760 B
Markdown
---
|
|
title: Functions
|
|
localeTitle: Funciones
|
|
---
|
|
## Funciones
|
|
|
|
Las funciones en Swift consisten en un parámetro y un tipo de retorno. Las funciones se pueden crear utilizando esta estructura básica: \`\` \`Swift func sayHello (nameOfPerson: String) -> String { let hola = "Hola," + nameOfPerson + "." imprimir (hola) }
|
|
|
|
sayHello (nameOfPerson: "Steve") ` `` In this example, the function sayHello takes in a string name and prints out the phrase` "Hola, Steve".
|
|
|
|
## Parámetros de función
|
|
|
|
Las funciones no requieren ningún parámetro de entrada o tipo de retorno. Sin embargo, esto requiere los paréntesis después de nombrar las funciones. \`\` \`Swift func helloSteve () { imprimir ("Hola, Steve") }
|
|
|
|
helloSteve () // Esto imprime "Hola, Steve". \`\` \` |