Functions Flashcards

1
Q

Functions

When overriding a method with default parameter values, the default parameter values must be ___ from the signature.

A

omitted

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

Functions

If a default parameter precedes a parameter with no default value, the default value can only be used by calling the function with ___ ___.

A

named arguments

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

Functions

If the last argument after default parameters is a lambda, you can pass it either as a named argument or ___ the ___.

A

outside; parenthesis

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

Functions

What is one important way calling a function with named arguments is helpful?

A

disambiguating the meaning of the parameters

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

Functions

You can pass a variable number of arguments (vararg) with names using the ___ operator.

A

spread

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

Functions

When a function returns a single expression, the curly braces can be omitted and the body is specified after a ___ symbol.

A

equals (=)

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

Functions

A parameter of a function (normally the last one) may be marked with ___ modifier, allowing a variable number of arguments to be passed to the function.

A

vararg

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

Functions

When we call a vararg-function, we can pass arguments one-by-one, or, if we already have an array and want to pass its contents to the function, we use the ___ operator (prefix the array with * ).

A

spread

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

Functions

Functions marked with the ___ keyword can also be called without the dot and parenthesis for the call.

A

infix

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

Functions

Infix functions must satisfy the following requirements:

A

They must be member functions or extension functions;

They must have a single parameter;

The parameter must not accept variable number of arguments and must have no default value

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

Functions

Kotlin supports local functions, i.e. a function inside another function. Local functions can access ___ variables of ___ functions.

A

local; outer

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

Functions

Kotlin supports a style of functional programming known as ___ ___. This allows some algorithms that would normally be written using loops to instead be written using a recursive function, but without the risk of stack overflow.

A

tail recursion

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

Functions

When a function is marked with the ___ modifier and meets the required form, the compiler optimizes out the recursion, leaving behind a fast and efficient loop based version instead.

A

tailrec

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

Functions

To be eligible for the tailrec modifier, a function must call itself as the ___ operation it performs.

A

last

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