Modifier Keywords & Special Identifiers Flashcards
The following tokens act as keywords in modifier lists of declarations and can be used as identifiers in other contexts: Special identifiers (field & it) are defined by the compiler in specific contexts and can be used as regular identifiers in other contexts:
actual
denotes a platform-specific implementation in multiplatform projects
abstract
marks a class or member as abstract
annotation
declares an annotation class
companion
declares a companion object
const
marks a property as a compile-time constant
crossinline
forbids non-local returns in a lambda passed to an inline function
data
instructs the compiler to generate canonical members for a class
enum
declares an enumeration
expect
marks a declaration as platform-specific, expecting an implementation in platform modules
external
marks a declaration as implemented not in Kotlin (accessible through JNI or in JavaScript).
final
forbids overriding a member
infix
allows calling a function in infix notation
inline
tells the compiler to inline the function and the lambdas passed to it at the call site
inner
allows referring to the outer class instance from a nested class
internal
marks a declaration as visible in the current module
lateinit
allows initializing a non-null property outside of a constructor
noinline
turns off inlining of a lambda passed to an inline function
open
allows subclassing a class or overriding a member
operator
marks a function as overloading an operator or implementing a convention
out
marks a type parameter as covariant
override
marks a member as an override of a superclass member
private
marks a declaration as visible in the current class or file
protected
marks a declaration as visible in the current class and its subclasses
public
marks a declaration as visible anywhere
reified
marks a type parameter of an inline function as accessible at runtime
sealed
declares a sealed class (a class with restricted subclassing)
suspend
marks a function or lambda as suspending (usable as a coroutine)
tailrec
marks a function as tail-recursive (allowing the compiler to replace recursion with iteration)
vararg
allows passing a variable number of arguments for a parameter
field
is used inside a property accessor to refer to the backing field of the property
it
is used inside a lambda to refer to its parameter implicitly