Congratulations on completing this lesson. Let’s go over what we learned:
- A function is a reusable block of code that can be invoked throughout a program.
- In order to execute a function, it must be called somewhere in the program.
- An argument is a piece of data fed to the function.
- Arguments have the option to be named and/or given default values.
- A return statement returns a piece of data from the function to where the function was called.
- Functions with only a single expression can be written with a single line of code using shorthand syntax.
- A function literal is an unnamed function that can be passed as an expression.
Use the space in Review.kt to practice using functions in Kotlin!
When you’re ready to move on, click Up Next.