# Keywords and operators ## Hard keywords The following tokens are always interpreted as keywords and cannot be used as identifiers: * `as` * is used for [type casts](typecasts.html#unsafe-cast-operator). * specifies an [alias for an import](packages.html#imports) * `as?` is used for [safe type casts](typecasts.html#unsafe-cast-operator). * `break` [terminates the execution of a loop](returns.html). * `class` declares a [class](classes.html). * `continue` [proceeds to the next step of the nearest enclosing loop](returns.html). * `do` begins a [do/while loop](control-flow.html#while-loops) (a loop with a postcondition). * `else` defines the branch of an [if expression](control-flow.html#if-expression) that is executed when the condition is false. * `false` specifies the 'false' value of the [Boolean type](booleans.html). * `for` begins a [for loop](control-flow.html#for-loops). * `fun` declares a [function](functions.html). * `if` begins an [if expression](control-flow.html#if-expression). * `in` * specifies the object being iterated in a [for loop](control-flow.html#for-loops). * is used as an infix operator to check that a value belongs to [a range](ranges.html), a collection, or another entity that [defines a 'contains' method](operator-overloading.html#in-operator). * is used in [when expressions](control-flow.html#when-expressions-and-statements) for the same purpose. * marks a type parameter as [contravariant](generics.html#declaration-site-variance). * `!in` * is used as an operator to check that a value does NOT belong to [a range](ranges.html), a collection, or another entity that [defines a 'contains' method](operator-overloading.html#in-operator). * is used in [when expressions](control-flow.html#when-expressions-and-statements) for the same purpose. * `interface` declares an [interface](interfaces.html). * `is` * checks that [a value has a certain type](typecasts.html#is-and-is-operators). * is used in [when expressions](control-flow.html#when-expressions-and-statements) for the same purpose. * `!is` * checks that [a value does NOT have a certain type](typecasts.html#is-and-is-operators). * is used in [when expressions](control-flow.html#when-expressions-and-statements) for the same purpose. * `null` is a constant representing an object reference that doesn't point to any object. * `object` declares [a class and its instance at the same time](object-declarations.html). * `package` specifies the [package for the current file](packages.html). * `return` [returns from the nearest enclosing function or anonymous function](returns.html). * `super` * [refers to the superclass implementation of a method or property](inheritance.html#calling-the-superclass-implementation). * [calls the superclass constructor from a secondary constructor](classes.html#inheritance). * `this` * refers to [the current receiver](this-expressions.html). * [calls another constructor of the same class from a secondary constructor](classes.html#constructors-and-initializer-blocks). * `throw` [throws an exception](exceptions.html). * `true` specifies the 'true' value of the [Boolean type](booleans.html). * `try` [begins an exception-handling block](exceptions.html). * `typealias` declares a [type alias](type-aliases.html). * `typeof` is reserved for future use. * `val` declares a read-only [property](properties.html) or [local variable](basic-syntax.html#variables). * `var` declares a mutable [property](properties.html) or [local variable](basic-syntax.html#variables). * `when` begins a [when expression](control-flow.html#when-expressions-and-statements) (executes one of the given branches). * `while` begins a [while loop](control-flow.html#while-loops) (a loop with a precondition). ## Soft keywords The following tokens act as keywords in the context in which they are applicable, and they can be used as identifiers in other contexts: * `by` * [delegates the implementation of an interface to another object](delegation.html). * [delegates the implementation of the accessors for a property to another object](delegated-properties.html). * `catch` begins a block that [handles a specific exception type](exceptions.html). * `constructor` declares a [primary or secondary constructor](classes.html#constructors-and-initializer-blocks). * `context` declares [context parameters](context-parameters.html) for functions and properties. * `delegate` is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `dynamic` references a [dynamic type](dynamic-type.html) in Kotlin/JS code. * `field` * declares an [explicit backing field](properties.html#explicit-backing-fields). * is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `file` is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `finally` begins a block that [is always executed when a try block exits](exceptions.html). * `get` * declares the [getter of a property](properties.html). * is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `import` [imports a declaration from another package into the current file](packages.html). * `init` begins an [initializer block](classes.html#constructors-and-initializer-blocks). * `param` is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `property` is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `receiver` is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `set` * declares the [setter of a property](properties.html). * is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `setparam` is used as an [annotation use-site target](annotations.html#annotation-use-site-targets). * `value` with the `class` keyword declares an [inline class](inline-classes.html). * `where` specifies the [constraints for a generic type parameter](generics.html#upper-bounds). ## Modifier keywords The following tokens act as keywords in modifier lists of declarations, and they can be used as identifiers in other contexts: * `abstract` marks a class or member as [abstract](classes.html#abstract-classes). * `actual` denotes a platform-specific implementation in [multiplatform projects](https://kotlinlang.org/docs/multiplatform/multiplatform-expect-actual.html). * `annotation` declares an [annotation class](annotations.html). * `companion` declares a [companion object](object-declarations.html#companion-objects). * `const` marks a property as a [compile-time constant](properties.html#compile-time-constants). * `crossinline` forbids [non-local returns in a lambda passed to an inline function](inline-functions.html#returns). * `data` instructs the compiler to [generate canonical members for a class](data-classes.html). * `enum` declares an [enumeration](enum-classes.html). * `expect` marks a declaration as [platform-specific](https://kotlinlang.org/docs/multiplatform/multiplatform-expect-actual.html), expecting an implementation in platform modules. * `external` marks a declaration as implemented outside of Kotlin (accessible through [JNI](java-interop.html#using-jni-with-kotlin) or in [JavaScript](js-interop.html#external-modifier)). * `final` forbids [overriding a member](inheritance.html#overriding-methods). * `infix` allows calling a function using [infix notation](functions.html#infix-notation). * `inline` tells the compiler to [inline a function and the lambdas passed to it at the call site](inline-functions.html). * `inner` allows referring to an outer class instance from a [nested class](nested-classes.html). * `internal` marks a declaration as [visible in the current module](visibility-modifiers.html). * `lateinit` allows initializing a [non-nullable property outside of a constructor](properties.html#late-initialized-properties-and-variables). * `noinline` turns off [inlining of a lambda passed to an inline function](inline-functions.html#noinline). * `open` allows [subclassing a class or overriding a member](classes.html#inheritance). * `operator` marks a function as [overloading an operator or implementing a convention](operator-overloading.html). * `out` marks a type parameter as [covariant](generics.html#declaration-site-variance). * `override` marks a member as an [override of a superclass member](inheritance.html#overriding-methods). * `private` marks a declaration as [visible in the current class or file](visibility-modifiers.html). * `protected` marks a declaration as [visible in the current class and its subclasses](visibility-modifiers.html). * `public` marks a declaration as [visible anywhere](visibility-modifiers.html). * `reified` marks a type parameter of an inline function as [accessible at runtime](inline-functions.html#reified-type-parameters). * `sealed` declares a [sealed class](sealed-classes.html) (a class with restricted subclassing). * `suspend` marks a function or lambda as suspending (usable as a [coroutine](coroutines-overview.html)). * `tailrec` marks a function as [tail-recursive](functions.html#tail-recursive-functions) (allowing the compiler to replace recursion with iteration). * `vararg` allows [passing a variable number of arguments for a parameter](functions.html#variable-number-of-arguments-varargs). ## Special identifiers The following identifiers are defined by the compiler in specific contexts, and they can be used as regular identifiers in other contexts: * `field` is used inside a property accessor to refer to the [backing field of the property](properties.html#backing-fields). * `it` is used inside a lambda to [refer to its parameter implicitly](lambdas.html#it-implicit-name-of-a-single-parameter). ## Operators and special symbols Kotlin supports the following operators and special symbols: * `+`, `-`, `*`, `/`, `%` - mathematical operators * `*` is also used to [pass an array to a vararg parameter](functions.html#variable-number-of-arguments-varargs). * `=` * assignment operator. * is used to specify [default values for parameters](functions.html#parameters-with-default-values). * `+=`, `-=`, `*=`, `/=`, `%=` - [augmented assignment operators](operator-overloading.html#augmented-assignments). * `++`, `--` - [increment and decrement operators](operator-overloading.html#increments-and-decrements). * `&&`, `||`, `!` - logical 'and', 'or', 'not' operators (for bitwise operations, use the corresponding [infix functions](numbers.html#bitwise-operations) instead). * `==`, `!=` - [equality operators](operator-overloading.html#equality-and-inequality-operators) (translated to calls of `equals()` for non-primitive types). * `===`, `!==` - [referential equality operators](equality.html#referential-equality). * `<`, `>`, `<=`, `>=` - [comparison operators](operator-overloading.html#comparison-operators) (translated to calls of `compareTo()` for non-primitive types). * `[`, `]` - [indexed access operator](operator-overloading.html#indexed-access-operator) (translated to calls of `get` and `set`). * `!!` [asserts that an expression is non-nullable](null-safety.html#not-null-assertion-operator). * `?.` performs a [safe call](null-safety.html#safe-call-operator) (calls a method or accesses a property if the receiver is non-nullable). * `?:` takes the right-hand value if the left-hand value is null (the [elvis operator](null-safety.html#elvis-operator)). * `::` creates a [member reference](lambdas.html#function-references) or a [class reference](reflection.html#obtain-a-runtime-class). * `.` * accesses [members](classes.html), including [nested classes](nested-classes.html) and [enum entries](enum-classes.html#working-with-enum-constants). * defines and calls [extensions](extensions.html). * qualifies names and [packages](packages.html). * separates the integer and fractional parts of a [floating-point literal](numbers.html#floating-point-types). * `..`, `..<` create [ranges](ranges.html). * `:` separates a name from a type in a declaration. * `?` marks a type as [nullable](null-safety.html#nullable-types-and-non-nullable-types). * `->` * separates the parameters and body of a [lambda expression](lambdas.html#lambda-expression-syntax). * separates the parameters and return type declaration in a [function type](lambdas.html#function-types). * separates the condition and body of a [when expression](control-flow.html#when-expressions-and-statements) branch. * `@` * introduces an [annotation](annotations.html#usage). * introduces or references a [loop label](returns.html#break-and-continue-labels). * introduces or references a [lambda label](returns.html#return-to-labels). * references a ['this' expression from an outer scope](this-expressions.html#qualified-this). * references an [outer superclass](inheritance.html#calling-the-superclass-implementation). * `;` separates multiple statements on the same line. * `$` references a variable or expression in a [string template](strings.html#string-templates). * `_` * substitutes an unused parameter in a [lambda expression](lambdas.html#underscore-for-unused-variables). * substitutes an unused parameter in a [destructuring declaration](destructuring-declarations.html#underscore-for-unused-variables). For operator precedence, see [this reference](https://kotlinlang.org/grammar/#expressions) in Kotlin grammar.