kotlin keywords Flashcards
as
- is used for type casts.
- specifies an alias for an import.
as?
is used for safe type casts.
break
terminates the execution of a loop.
class
declares a class.
continue
proceeds to the next step of the nearest enclosing loop.
do
begins a do/while loop (loop with postcondition).
else
defines the branch of an ‘if expression’ which is executed when the condition is false.
false
specifies the ‘false value’ of the Boolean type.
for
begins a “for loop”.
fun
declares a function.
if
begins an “if expression”.
in
- specifies the object being iterated in a ‘for loop’.
- is used as an infix operator to check that a value belongs to ‘a range’, a collection or another entity that defines the ‘contains method.’
- is used in ‘when expressions’ for the same purpose.
- marks a type parameter as ‘contravariant’.
!in
- is used as an operator to check that a value does NOT belong to ‘a range’ , a collection or another entity that ‘defines the ‘contains method’.
is used in ‘when expressions’ for the same purpose.
interface
declares an ‘interface’ .
is
- checks that ‘a value does NOT have a certain type’ .
- is used in ‘when expressions’ for the same purpose.
null
is a constant representing an object reference that does not point to any object.
object
declares ‘a class and its instance at the same time.
package
specifies the ‘package for the current file’ .
return
‘returns from the nearest enclosing function or anonymous function’ .
super
- ‘refers to the superclass implementation of a method or property’ .
- ‘calls the superclass constructor from a secondary constructor’ .
this
- refers to the ‘current receiver’ .
- ‘calls another constructor of the same class from a secondary constructor’ .
throw
‘throws an exception’ .
true
specifies the ‘true’ value of the ‘Boolean Type’ .
try
‘begins an exception handling block’ .
typealias
declares ‘a type alias’ .
typeof
reserved for future use.
val
declares a read-only ‘property’ or ‘local variable’ .
var
declares a mutable ‘property’ or ‘local variable’ .
when
begins a ‘when expression’ (executes on of the given branches).
while
begins a ‘while loop’ (loop with precondition).