15 lines
727 B
Markdown
15 lines
727 B
Markdown
---
|
|
title: Functions
|
|
localeTitle: Funções
|
|
---
|
|
## Funções
|
|
|
|
Funções no Swift consiste em um parâmetro e um tipo de retorno. Funções podem ser criadas usando essa estrutura básica: \`\` \`Swift func sayHello (nameOfPerson: String) -> String { vamos hello = "Olá", + nameOfPerson + "." imprimir (ola) }
|
|
|
|
sayHello (nameOfPerson: "Steve") ` `` In this example, the function sayHello takes in a string name and prints out the phrase` "Hello, Steve".
|
|
|
|
## Parâmetros de Função
|
|
|
|
Funções não requerem parâmetros de entrada ou tipos de retorno. No entanto, isso requer os parênteses depois de nomear as funções. \`\` \`Swift func helloSteve () { print ("Olá, Steve") }
|
|
|
|
helloSteve () // Imprime "Olá, Steve". \`\` \` |