Add style and correct syntax (#22444)
Should the function names be kept in English, since it's the language developers will use for their apps? Maybe the data inside the vars can be in Spanish.
This commit is contained in:
committed by
Christopher McCormack
parent
a32f719d3a
commit
c309fe0fdf
@ -4,12 +4,24 @@ localeTitle: Funciones
|
|||||||
---
|
---
|
||||||
## 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) }
|
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 hello = "Hola," + nameOfPerson + "."
|
||||||
|
print(hello)
|
||||||
|
}
|
||||||
|
|
||||||
sayHello (nameOfPerson: "Steve") ` `` In this example, the function sayHello takes in a string name and prints out the phrase` "Hola, Steve".
|
sayHello(nameOfPerson: "Steve")
|
||||||
|
```
|
||||||
|
En este ejemplo, la función sayHello coge una cadena de palabras e imprime la frase `"Hola, Steve."`.
|
||||||
|
|
||||||
## Parámetros de función
|
## 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") }
|
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() {
|
||||||
|
print("Hola, Steve.")
|
||||||
|
}
|
||||||
|
|
||||||
helloSteve () // Esto imprime "Hola, Steve". \`\` \`
|
helloSteve() // Esto imprime "Hola, Steve."
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user