Swift Types & FunctionsLesson 21Free preview
Swift Functions
This lesson is part of Swift · All levels
Summary
This lesson reviews functions in Swift that are declared using the keyword 'func'. Swift has a very expressive parameter feature, where each parameter can have an external label argument and an internal name parameter. The developer will also study the value of the compound return using tuple, default parameters, and in-out parameters.
Key points
- Function is declared with 'func namaFungsi(param: Tipe) -> TypeReturn'
- Supports external label arguments to clarify natural English-like pronunciation
- Use '_' in front of the parameter name to ignore the label argument when calling
- The keyword 'inout' allows modification of the value of the original variable from within the function (pass by reference)
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.