Functions Flashcards
Functions
When overriding a method with default parameter values, the default parameter values must be ___ from the signature.
omitted
Functions
If a default parameter precedes a parameter with no default value, the default value can only be used by calling the function with ___ ___.
named arguments
Functions
If the last argument after default parameters is a lambda, you can pass it either as a named argument or ___ the ___.
outside; parenthesis
Functions
What is one important way calling a function with named arguments is helpful?
disambiguating the meaning of the parameters
Functions
You can pass a variable number of arguments (vararg) with names using the ___ operator.
spread
Functions
When a function returns a single expression, the curly braces can be omitted and the body is specified after a ___ symbol.
equals (=)
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.
vararg
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 * ).
spread
Functions
Functions marked with the ___ keyword can also be called without the dot and parenthesis for the call.
infix
Functions
Infix functions must satisfy the following requirements:
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
Functions
Kotlin supports local functions, i.e. a function inside another function. Local functions can access ___ variables of ___ functions.
local; outer
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.
tail recursion
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.
tailrec
Functions
To be eligible for the tailrec modifier, a function must call itself as the ___ operation it performs.
last