Kotlin Concepts Flashcards

1
Q

Kotlin functions are first-class, which means?

A

they can be stored in variables and data structures, and can be passed as arguments to and returned from other higher-order functions.

You can perform any operations on functions that are possible for other non-function values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Kotlin, as a statically typed programming language means?

A

variable types are explicitly declared and thus are determined at compile time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Higher-order function?

A

a function that takes functions as parameters, or returns a function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

All function types have a parenthesized list of parameter types and a return type: (A, B) -> C
What does this denote?

A

denotes a type that represents functions that take two arguments of types A and B and return a value of type C. The list of parameter types may be empty, as in () -> A. The Unit return type cannot be omitted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Function types can optionally have an additional receiver type, which is specified before the dot in the notation: the type A.(B) -> C
What does this represent?

A

represents functions that can be called on a receiver object A with a parameter B and return a value C.

Function literals with receiver are often used along with these

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Suspending functions belong to a special kind of function type that…?

A

have a suspend modifier in their notation, such as suspend () -> Unit or suspend A.(B) -> C.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

To specify that a function type is nullable use… ?

A

parentheses as follows: ((Int, Int) -> Int)?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

You can also give a function type an alternative name by…?

A

using a type alias:

typealias ClickHandler = (Button, ClickEvent) -> Unit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

function literals are?

A

functions that are not declared but are passed immediately as an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Name two types of function literals?

A

Lambda expressions & anonymous functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly