Files
freeCodeCamp/guide/russian/swift/functions/index.md
2018-11-20 20:53:14 +04:00

28 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Functions
localeTitle: Функции
---
## Функции
Функции в Swift состоят из параметров и возвращаемого типа. Функции могут быть созданы с использованием этой базовой структуры:
```Swift
func sayHello(nameOfPerson: String) -> String {
let hello = "Привет, " + nameOfPerson + "."
print(hello)
}
sayHello (nameOfPerson: "Стив")
```
В данном примере, функция `sayHello` принимает строку, содержащюю имя, как параметр и печатает фразу `«Привет, Стив.»`.
## Параметры функции
Функции не требуют ввода входных параметров или возвращаемых типов. Однако скобки после имен функций являются обязательными.
```Swift
func helloSteve () {
print ("Привет, Стив.")
}
helloSteve () // Это выводит «Привет, Стив.»
```