Functions

San Skulrattanakulchai

March 6, 2020

Topics

Function types

Examples

Writing function types

First-class citizens

Function literals

Syntax of lambda expressions

Examples

Return values of lambda expressions

Exercise

What is it?

Syntax of anonymous functions

Anonymous function example

Syntax of anonymous functions, continued

Defining functions

Defining functions, continued

Defining functions, continued

Calling functions

Calling functions using positional arguments, continued

Default arguments

Named arguments

Nested functions

Example nested function

Higher-order functions

Function argument

IntArray constructor

IntArray constructor

A syntactic sugar

Arrays of non-primitive types

Two-dimensional arrays

Function returning function value