Title: Theory / Unimportant / CS / Programming / Kotlin / Language
Tags: computer_to_instruction declaration todo_declaration automatedNewLineAfterCommaSpace FromInstruction comment hasNotNewEffectReturnsMeaning how some_instruction

Instruction: is_array(value)
Page: 6
Effect: detecting whether value is an array
Language: js
Section: 61
Assuming: must be defined

Instruction: package foo
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: State that the current file belong to package foo
Language: kotlin
Where to use it: on first line

Instruction: fun main() {
  bar
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: When the program is run, it executes bar
Language: kotlin

Instruction: fun main(args: Array<String>) {
  bar
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: When the program is run, it executes bar where args is the array of command-line arguments
Language: kotlin

Instruction: print(foo)
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: Print foo on the standard output
Language: kotlin

Instruction: println(foo)
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: Print foo and a new line on the standard output
Language: kotlin

Instruction: fun name(args) = expr
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Define name as a function from args returning the expr
Language: kotlin

Typ: Unit
Meaning: A type with a unique value.
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: kotlin
Intuition: void in most language.

Instruction: fun name (args): type {
  bar;
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Define a function name taking arguments args, returning a value of type type and executing bar
Language: kotlin

Instruction: fun name (args) {
  bar;
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Define a function name taking arguments args, executing bar and not returning anything
Language: kotlin

Instruction: varName: Type
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Introduce a variable with name varName of type Type
Language: Kotlin
Context: arguments

Instruction: val name: type = value;
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Introduce a constant name of type type with value value
Language: Kotlin

Instruction: val name = value;
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Introduce a constant name of inferred type with value value
Language: Kotlin

Instruction: val name: type;
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Introduce a constant name of type type whose constant value is deferred
Language: Kotlin

Instruction: var name = value;
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Introduce a variable name with initial value value
Language: Kotlin

Instruction: name = value;
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: change name value's to value
Language: Kotlin
Assuming: name is a variable

Instruction: class ClassName constructor(declarations_constructor) {
  declarations;
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Define a class ClassName with members as in declarations_constructor from constructor and in declarations;
Language: Kotlin
Name: Primany constructor
Abbreviation: class ClassName(declarations_constructor) {
  declarations;
}

Instruction: class ClassName(
  declarations_constructor
) : Parent_1,
  ..,
  Parent_n {
  declarations;
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Meaning: Define a class ClassName with members as in declarations_constructor from constructor and in declarations; inheriting Parent_i
Language: Kotlin

Language: Kotlin
Abbreviation: // one line comment
Instruction: /* multi
 line
comment*/
Other fields (not shown on cards):
Page: https://kotlinlang.org/docs/basic-syntax.html

Instruction: $varName
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: the value associated to varName
Where to use it: in a string

Instruction: ${expression}
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: the value of expression
Where to use it: in a string

Instruction: if (foo)
   bar
else
  plop
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: execute bar if foo holds otherwise plop
Language: Kotlin
Returns: bar if foo holds otherwise plop

Instruction: listOf(
  val_1,
  ...,
  val_n
)
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: A read-only list with whose \(  i\)th element is val_i

Instruction: list.indices
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: The list of indices of list
Variables: list a List

Instruction: for (var in iterable) {
  foo
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: Execute foo with var taking each value in iterable
Language: Kotlin
Variables: list a List

Instruction: while (cond) {
  foo
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: if not cond, do nothing
otherwise, execute foo and start from scratch
Language: Kotlin

Instruction: when (expression) {
  cond_1 -> value_1
  ...
  cond_n -> value_n
  else -> default_value
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: val valName = expression;
if cond_i(valName) is the first truthful condition, then value_i, if there is no such i then default_value

Instruction: i..j
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: The range of ints between i and j included
Variables: i,j int

Instruction: value in set
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: Whether value belongs in set
Variables: set a set
value

Instruction: value !in set
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: Whether value does not belong in set
Variables: set a set
value

Instruction: i downTo j
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: A progression from i to j descending
Variables: i, j: int

Instruction: i downTo j step n
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: A progression from i to j descending with steps of size n
Variables: i, j, n: int

Instruction: i..j step n
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: A progression from i to j ascending with steps of size n
Variables: i, j, n: int

Instruction: when {
  cond_1 -> value_1
  ...
  cond_n -> value_n
  else -> default_value
}
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: if cond_1 is the first truthful value, then value_1, if no such i exists then default_value

Instruction: col.filter {function}
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: The collection of elements it from col such that function(it)
Variables: col a collection

Instruction: col.sortedBy {function}
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: The collection col, sorted according to function(elt)
Variables: col a collection

Instruction: col.map {function}
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: The collection of function(elt) for elt in col
Variables: col a collection

Instruction: col.forEach {bar}
Page: https://kotlinlang.org/docs/basic-syntax.html
Effect: Execute bar(elt) for each elt in col
Language: Kotlin
Variables: col a collection

Typ: type?
Meaning: Either type or null
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Variables: col a collection
Implementation: In JVM: it's a (possibly null) reference to an object of type type

Instruction: value is type
Page: https://kotlinlang.org/docs/basic-syntax.html
Language: Kotlin
Returns: Whether value is of type type
Variables: col a collection

Instruction: var.toString()
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: A string representing the value of var

Instruction: var.hashCode()
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: A hash value for the value of var

Instruction: var_1.equals(var_2)
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: Whether var_1 equals var_2

Instruction: val.copy()
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: A copy of val

Instruction: data class className(args_declaration)
Page: https://kotlinlang.org/docs/idioms.html
Meaning: Create a data class, with a constructor as in args_declaration, with vals non-mutable and vars mutable.
the function componentn() return the n-th element of args_declaration
Language: Kotlin
Intuition: allow to return/pass around multiple values with some more specific description than Pair<>

Instruction: expression containing it
Page: https://kotlinlang.org/docs/idioms.html
https://kotlinlang.org/docs/lambdas.html#it-implicit-name-of-a-single-parameter
Language: Kotlin
Returns: it -> expression
Variables: col a collection

Instruction: value_2
Page: https://kotlinlang.org/docs/basic-syntax.html#program-entry-point
Language: Kotlin
Returns: Whether value.equals (value_2)
Variables: col a collection
Where to use it: where (value) cases

Instruction: is type
Page: https://kotlinlang.org/docs/basic-syntax.html#program-entry-point
Language: Kotlin
Returns: Whether value's type is type
Variables: col a collection
Where to use it: where (value) cases

Instruction: mapOf(
  key_1 to val_1,
  ...,
  key_n to val_n
)
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: A constant map from key_i to val_i
Variables: col a collection

Instruction: map[key] = value
Page: https://kotlinlang.org/docs/idioms.html
Effect: Set the value associated to key in map to value
Language: Kotlin
Variables: map a map

Instruction: map[key]
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: The value associated to key in map
Variables: map a map

Instruction: map (as an iterator)
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: The sequence of pairs (key, value) of the map
Variables: map a Map

Instruction: type by lazy {
  expr
}
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: A lazy version of expr

Instruction: fun Class.functionName(args) {foo}
Page: https://kotlinlang.org/docs/idioms.html
Meaning: Define functionName(args) {foo} as a method of Class
Language: Kotlin
Name: Extension function

Instruction: object objectName {
  declarations;
}
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: An object with values as in the declaration, not belonging to a class
Name: singleton

Instruction: abstract class Foo {
   ...
}
Page: https://kotlinlang.org/docs/idioms.html
Meaning: Define an abstract class
Language: Kotlin

Instruction: abstract fun functionName(args): type;
Page: https://kotlinlang.org/docs/idioms.html
Meaning: Define an abstract function functionName with args and return type
Language: Kotlin
Assuming: Abstract class

Instruction: override fun functionName(args): type;
Page: https://kotlinlang.org/docs/idioms.html
Meaning: Define functionName as overriding a method of same type in the parent class
Language: Kotlin
Assuming: Abstract class

Instruction: col.firstOrNull()
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Returns: Either the first element of col if it exists, otherwise null
Variables: col a Collection

Instruction: throw Exception
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin
Typ: Nothing

Instruction: try {
 body
} catch (exceptionName: ExceptionType_1) {
  catchCase_n
} ... catch (exceptionName: ExceptionType_n) {
  catchCase_n
} finally {
   finalCode
}
Page: https://kotlinlang.org/docs/idioms.html
Effect: Execute body up to the first uncatched exception e if any. If ExceptionType_i is the first type of e then execute catchCase_i.
In any case, execute finalCode
Language: Kotlin
Returns: either the returned value of body if it executes without raising any exception. If ExceptionType_i is the first type of e then the value returned by catchCase_i.

Instruction: with (object) {
  bar
}
Page: https://kotlinlang.org/docs/idioms.html
Effect: Execute bar where all methods are applied to the object object
Language: Kotlin

Instruction: .use ?
Page: https://kotlinlang.org/docs/idioms.html
Effect: explain
Language: Kotlin

Instruction: <reified T: Type>
Page: https://kotlinlang.org/docs/idioms.html
Meaning: Introduce a variable type T which extends Type
Language: Kotlin

Instruction: inline fun
Page: https://kotlinlang.org/docs/inline-functions.html
Meaning: Same as fun, but the function defined is never actually called, it's content is replaced by the function. Similarly, the lambdas passed to it is not actually passed but replaced by the code
Language: Kotlin
Assuming: if fun is public, it can't use private or internal call

Typ: Nothing
Meaning: A type without value
Page: https://kotlinlang.org/docs/idioms.html
Language: Kotlin

Instruction: TODO(foo)
Page: https://kotlinlang.org/docs/idioms.html
Effect: throw NotImplementedError(Foo)
Language: Kotlin
Typ: Nothing
Intuition: Indicate that this part of the code is missing without stopping compiling

Extension: kt
Means: kotlin
Other fields (not shown on cards):
Page: https://kotlinlang.org/docs/coding-conventions.html#source-file-organization

Typ: Byte, Short, Int, Long, Double, Float
Meaning: JVM's byte, short, int, long, double, float
Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Language: kotlin
Index: kt

Typ: Byte?, Short?, Int?, Long?, Double?, Float?
Meaning: JVM's Byte, Short, Integer, Long, Double, Float
Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Language: kotlin
Index: kt

Instruction: val_1 === val_2
Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Language: kotlin
Returns: Whether val_1 and val_2 are the same object
Index: kt

Instruction: bitwise operation
Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Language: kotlin
Returns: todo
Index: kt

Question: How is boolean arithmetic?
Answer: as in Java
Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Context: kotlin

Question: How is bitwise arithmetic?
Answer: infix, with name in latin letters, no symbols
Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Context: kotlin

Instruction: arraysOfNulls(n)
Page: https://kotlinlang.org/docs/basic-types.html#arrays
Language: Kotlin
Returns: An array with n nulls

Typ: FooArray
Meaning: Array of type Foo
Page: https://kotlinlang.org/docs/basic-types.html#arrays
Language: Kotlin
Variables: Foo primitive
Assuming: Foo is primitive type

Name: Smart cast
Definition: The fact that if a test ensured some information about the type of a variable, then this information is used in the type analysis
Page: https://kotlinlang.org/docs/typecasts.html#is-and-is-operators
Variables: Foo primitive
Context: Kotlin

Instruction: varName as Type
Page: https://kotlinlang.org/docs/typecasts.html#is-and-is-operators
Language: kotlin
Returns: varName interpreted as a value of type Type
Name: Unsafe cast

Instruction: varName as? Type
Page: https://kotlinlang.org/docs/typecasts.html#is-and-is-operators
Language: kotlin
Returns: varName interpreted as a value of type Type if possible, else null
Typ: Type?
Name: safe cast

Question: Why is there no ternary operator?
Answer: If/else already return a value
Page: https://kotlinlang.org/docs/control-flow.html
Context: Kotlin

Instruction: {
  instruction_1
  ...
  instruction_n
}
Page: https://kotlinlang.org/docs/control-flow.html
Effect: Execute instructions from instruction_1 to instruction_n or up to the first return/exception thrown
Language: kotlin
Returns: the value of instruction_n

Instruction: cond_1, ..., cond_n
Page: https://kotlinlang.org/docs/control-flow.html
Effect: Any of the cond_i holds
Language: kotlin
Where to use it: when

Instruction: ar.withIndex
Page: https://kotlinlang.org/docs/control-flow.html
Language: kotlin
Returns: iterator over indices and values of ar
Where to use it: when

Instruction: do {
  body
} while (cond)
Page: https://kotlinlang.org/docs/control-flow.html
Effect: Execute body
if cond then start again
Language: kotlin

Instruction: return
Page: https://kotlinlang.org/docs/returns.html
Effect: End the `fun` and don't return anything
Language: kotlin

Instruction: return foo
Page: https://kotlinlang.org/docs/returns.html
Effect: End the innermost `fun` and return the value foo
Language: kotlin

Instruction: labelName@ expression
Page: https://kotlinlang.org/docs/returns.html
Effect: Give label labelName to expression, execute the expression
Language: kotlin

Instruction: break@labelName
Page: https://kotlinlang.org/docs/returns.html
Effect: Quit the expression labelled by labelName
Language: kotlin

Instruction: break
Page: https://kotlinlang.org/docs/returns.html
Effect: Quit the innermost loop
Language: kotlin

Instruction: continue
Page: https://kotlinlang.org/docs/returns.html
Effect: Execute again the innermost loop
Language: kotlin

Instruction: continue@LabelName
Page: https://kotlinlang.org/docs/returns.html
Effect: Execute again the expression labelled by LabelName
Language: kotlin

Instruction: return@LabelName
Page: https://kotlinlang.org/docs/returns.html
Effect: Exit the part of code in braces labelled with LabelName
Language: Kotlin

Name: Implicit label
Definition: Labelling a part of the code by the name of the operation applied to it.
Page: https://kotlinlang.org/docs/returns.html
Context: Kotlin
Example: forEach is the implicy label of the innermost {}
Applied to: fun foo() {
    listOf(1, 2, 3, 4, 5).forEach {
        if (it == 3) return // non-local return directly to the caller of foo()
        print(it)
    }
    println("this point is unreachable")
}

Instruction: return@label value
Page: https://kotlinlang.org/docs/returns.html
Effect: Quit the block of code labelled by label and return the value
Language: Kotlin

Instruction: import foo1. ... .foon
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: foon represents foo1. ... .foon in this file
Language: Kotlin

Instruction: import foo_1. ... .foo_n as bar
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: bar represents foo_1. ... .foo_n in this file
Language: Kotlin

Instruction: import foo_1. ... .foo_n.*
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: All content of package foo_1. ... .foo_n is accessible in this file
Language: Kotlin

Instruction: init {
  block
}
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: During construction, execute block
Language: Kotlin
Where to use it: constructor

Instruction: constructor(args) : this(params) {
  body
}
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: create a constructor for the enclosing class, taking args, delegating to primary constructor with params and then executing body
Language: Kotlin
Where to use it: class
Name: Secondary constructor

Instruction: open class
Page: https://kotlinlang.org/docs/packages.html#imports
Meaning: same as class but can be inherited
Language: Kotlin

Instruction: super(params)
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: call the constructors of the parent class
Language: Kotlin

Instruction: open fun
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: same as fun but can be overriden
Language: Kotlin

Instruction: final override fun
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: same as override fun, but can't be overriden
Language: Kotlin

Instruction: super<Type>.member
Page: https://kotlinlang.org/docs/packages.html#imports
Language: Kotlin
Returns: The value of member in the parent class Type

Instruction: val/var name : Type
   get() = plop
Page: https://kotlinlang.org/docs/packages.html#imports
Meaning: When object.name is called, it executes and return plop
Language: Kotlin
Variables: object: Class
Where to use it: Class

Instruction: val/var name : Type
   set(value) = plop
Page: https://kotlinlang.org/docs/packages.html#imports
Meaning: When object.name = value is called, it executes and return plop(value)
Language: Kotlin
Variables: object: Class
Where to use it: Class

Instruction: val/var name : Type
   modifier/annotation get/set
Page: https://kotlinlang.org/docs/packages.html#imports
Meaning: change the modifier and/or annotation of the getter/setter without redefining it
Language: Kotlin
Variables: object: Class
Where to use it: Class

Instruction: field
Page: https://kotlinlang.org/docs/packages.html#imports
Language: Kotlin
Returns: a field of the same type as member
Where to use it: Class' member getter or setter of member
Name: backing field

Instruction: const val
Page: https://kotlinlang.org/docs/packages.html#imports
Meaning: same as val but noted as compile-time constant and optimized
Language: Kotlin

Instruction: lateinit var
Page: https://kotlinlang.org/docs/packages.html#imports
Effect: indicate that the value is initalized after the constructor
Language: Kotlin

Instruction: varName.isInitialized
Page: https://kotlinlang.org/docs/packages.html#imports
Language: Kotlin
Returns: Whether varName is already initialized

Name: interface
Definition: A class whose properties have no backing fields
Page: https://kotlinlang.org/docs/interfaces.html
Context: Kotlin

Name: Single Abstract Method
Definition: An interface containing a single abstract function
Context: Kotlin
Abbreviation: SAM

Name: public
Definition: a member that can be accessed everywhere
Context: Kotlin

Name: private
Definition: a member that can be accessed only in the file where it is declared
Context: Kotlin toplevel

Name: internal
Definition: an element that can be accessed only in the module where it is declared
Context: Kotlin toplevel

Question: What is the default visibility modifier
Answer: public
Context: Kotlin toplevel

Name: public
Definition: that any client who sees the declaring class sees its public members.
Context: Kotlin classes/interface

Name: internal
Definition: Can be seen by any client inside this module
Context: Kotlin classes/interface

Name: protected
Definition: same as private, but is also visible in subclasses
Context: Kotlin classes/interface

Name: private
Definition: visible inside this class only (including all its members).
Context: Kotlin classes/interface

Name: module
Definition: an IntelliJ IDEA module
Context: Kotlin classes/interface
Definition2: a Maven project
Definition3: a Gradle source set (with the exception that the test source set can access the internal declarations of main)
Definition4: a set of files compiled with one invocation of the <kotlinc> Ant task
DefType: A set of Kotlin files compiled together

Instruction: fun Class.methodName(args) {
  body;
}
Effect: Define a new method methodName(args) {body} on variable of type Class.
Language: Kotlin
Context: Kotlin classes/interface
Extra: The actual type of the object don't matter. Only tehe variable type matter
Name: Extension function

Instruction: val Class.property: Type
  get() = expr
Effect: Variables of type Class have a property of Type defined by expr
Language: Kotlin
Context: Kotlin classes/interface
Name: Extension property

Name: A receiver
Definition: An object on which a method is called
Context: Kotlin

Name: An implicit receiver
Definition: An object on which a method is called, which is understood by the context and not explicitly written
Context: Kotlin

Name: A dispatch receiver
Definition: In a method declaration, the object whose instance is the class in which the method is defined
Context: Kotlin

Name: An extension receiver
Definition: In a method declaration, the object whose instance is the class being extended
Context: Kotlin

Instruction: sealed class
Page: https://kotlinlang.org/docs/sealed-classes.html#additional-location-the-same-package
Effect: same as open class, but all direct child should be placed in the same file
Language: Kotlin
Intuition: Generalize enum

Instruction: out T
Effect: A variable parameter T that can only appear in out-position
Language: Kotlin

Name: variance annotation
Definition: Annotation indicating whether a type variable is variant (in) or covariant (out)
Context: Kotlin

Name: Declaration-site variance
Definition: A variance declared when the type is introduced
Context: Kotlin

Name: use-site variance
Definition: A variance declared when the type is used
Context: Kotlin

Typ: in T
Meaning: Variable T that can only be used in in-position
Language: Kotlin

Typ: T: Type
Meaning: Restrict T to be a type variable extending Type
Page: https://kotlinlang.org/docs/generics.html#generic-constraints
Language: Kotlin

Instruction: where T_1: Type_1, ..., T_n: Type_n
Page: https://kotlinlang.org/docs/generics.html#generic-constraints
Effect: Restrict the variable T_i to extend Type_i
Language: Kotlin
Extra: A same T can be opened multiple time

Name: A nested class
Definition: A class, defined inside another class, with no relation to a particular instance of the outer class object
Page: https://kotlinlang.org/docs/nested-classes.html
Context: Kotlin

Instruction: inner class
Page: https://kotlinlang.org/docs/nested-classes.html
Effect: define a class, which as access to the outer class instance
Language: Kotlin
Name: An inner class

Instruction: object: ParentClass(ParentConstructors) {
  body
}
Page: https://kotlinlang.org/docs/nested-classes.html
Effect: define an object, with anonymous class, inheriting ParentClass with ParentConstructors argument, plus definition of body
Language: Kotlin
Name: Anonymous class

Instruction: enum class EnumName {
  value_1, ..., value_n
}
Page: https://kotlinlang.org/docs/enum-classes.html
Meaning: Define a type EnumNameDefine constants value_i of this type
Language: Kotlin

Instruction: enum class EnumName(PropertiesList) {
  value_1(args_1),
   ...,
   value_n(args_n)
}
Page: https://kotlinlang.org/docs/enum-classes.html
Meaning: Define a type EnumName which have properties PropertiesListDefine constants value_i of this type with the property args_i
Language: Kotlin

Instruction: enum class EnumName(
  PropertiesList
) {
  value_1{body_1},
   ...,
   value_n{body_n};
   abstract fun funName_1(
  args_1
): Type_1
   ...
   abstract fun funName_m(
  args_m
): Type_m
}
Page: https://kotlinlang.org/docs/enum-classes.html
Meaning: Define a type EnumName which is an abstract class, whose implementations are only the value_i.
Define value_i which is an instance of the class EnumName with implementation as is body_i
Language: Kotlin

Instruction: EnumClassName.valueOf(EnumValueName)
Page: https://kotlinlang.org/docs/enum-classes.html
Language: Kotlin
Returns: The element of this enum with name EnumValueName
Variables: EnumClassName an enum class

Instruction: EnumClassName.values()
Page: https://kotlinlang.org/docs/enum-classes.html
Language: Kotlin
Returns: The array of elements of EnumClassName
Variables: EnumClassName an enum class

Question: What is the order of an Enum class?
Answer: the order in which elements are defined
Page: https://kotlinlang.org/docs/enum-classes.html
Variables: EnumClassName an enum class
Context: Kotlin

Question: inline class
Answer: todo after beta
Page: https://kotlinlang.org/docs/inline-classes.html#members
Variables: EnumClassName an enum class
Context: Kotlin

Instruction: companion object :  decl
Page: https://kotlinlang.org/docs/inline-classes.html#members
Effect: create an object, associated with ClassName
Language: Kotlin
Variables: class ClassName
Where to use it: class declaration

Instruction: : ParentName by objectName
Page: https://kotlinlang.org/docs/inline-classes.html#members
Effect: Indicate that the class derives ParentName and all methods from ParentName should be implemented using the method of same name on objectName
Language: Kotlin
Variables: class ClassName
Where to use it: class declaration
Name: Delegation

Instruction: var/val propertyName : TypeName by Implementation
Page: https://kotlinlang.org/docs/inline-classes.html#members
Meaning: Indicate that getter/setter of propertyName comes from Implementation.'s getValue and setValue
Language: Kotlin
Name: Property delegation
Variables: class ClassName

Typ: Lazy<T>
Meaning: a property getter of type T
Page: https://kotlinlang.org/docs/inline-classes.html#members
Language: Kotlin
Variables: class ClassName

Instruction: var varName: TypeName by Delegates.observable(
  ""
) {
   prop,
  old,
  new -> {block}
}
Page: https://kotlinlang.org/docs/inline-classes.html#members
Meaning: When varName is assigned,
  block is executed
Language: Kotlin
Variables: class ClassName

Instruction: var varName: TypeName by Delegates.vetoable(
  ""
) {
   prop,
  old,
  new -> {block}
}
Page: https://kotlinlang.org/docs/inline-classes.html#members
Meaning: When varName is assigned,
  block is executed. The execution is executed only if it returns true
Language: Kotlin
Variables: class ClassName

Instruction: typealias foo = bar
Page: https://kotlinlang.org/docs/type-aliases.html
Meaning: Introduce foo as a type which is semantically equal to bar
Language: Kotlin

Instruction: argName : typeName = defaultExpr
Page: https://kotlinlang.org/docs/type-aliases.html
Effect: add an argument argName of type typeName. IF a value is not given, expression defaultExpr is used instead
Language: Kotlin
Where to use it: function arguments

Instruction: argName : typeName,
Page: https://kotlinlang.org/docs/type-aliases.html
Effect: add an argument argName of type typeName. This argName is mandatory
Language: Kotlin
Where to use it: function arguments

Instruction: vararg argName : typeName,
Page: https://kotlinlang.org/docs/type-aliases.html
Effect: An arbitrary number of value of type typeName can be given during the function call
Language: Kotlin
Where to use it: function arguments

Instruction: *array
Page: https://kotlinlang.org/docs/type-aliases.html
Effect: Uses the array's content as varargs
Language: Kotlin
Where to use it: function call

Instruction: infix fun ClassName.MethodName(varName: TypeName) : ReturnTypeName {
  body
}
Page: https://kotlinlang.org/docs/type-aliases.html
Effect: Introduce an infix function for type ClassName taking a single argument varName, executing body
Language: Kotlin

Name: local function
Definition: A function defined in the body of another function
Page: https://kotlinlang.org/docs/functions.html#local-functions
Context: Kotlin

Name: member function
Definition: A function defined inside a class or object
Page: https://kotlinlang.org/docs/functions.html#local-functions
Context: Kotlin

Name: generic function
Definition: A function which takes generic parameter
Page: https://kotlinlang.org/docs/functions.html#local-functions
Context: Kotlin

Instruction: tailrec fun
Page: https://kotlinlang.org/docs/functions.html#local-functions
Effect: same as fun, but optimized to be tail recursive
Language: Kotlin

Typ: (args) -> returnType
Meaning: Type of functions taking args and returning returnType
Page: https://kotlinlang.org/docs/functions.html#local-functions
Language: Kotlin

Typ: ReceiverType.(args) -> returnType
Meaning: Type of method, to be applied to an object of type ReceiverType taking args and returning returnType
Page: https://kotlinlang.org/docs/functions.html#local-functions
Language: Kotlin

Typ: suspend (args) -> returnType
Meaning: Type of suspend fuction, taking arguments as in args and returning returnType
Page: https://kotlinlang.org/docs/functions.html#local-functions
Language: Kotlin

Instruction: {args -> expr}
Page: https://kotlinlang.org/docs/functions.html#local-functions
Language: Kotlin
Returns: A function taking args and returning expr
Name: lambda expression

Instruction: fun(args): returnType {
  block
}
Page: https://kotlinlang.org/docs/functions.html#local-functions
Language: Kotlin
Returns: A function taking args and executing block
Name: Anonymous function

Instruction: ::topLevelFunctionName or ::ConstructorName
Page: https://kotlinlang.org/docs/functions.html#local-functions
Language: Kotlin
Returns: The function topLevelFunctionName as a first-order value

Instruction: ClassName::topLevelFunctionName
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Language: Kotlin
Returns: The method from ClassName at  topLevelFunctionName as a first-order value

Instruction: f.invoke(params)
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Effect: Apply f to params
Language: Kotlin
Variables: fun a value of function type
Abbreviation: f(params)

Instruction: f.invoke(receiver, params)
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Effect: Apply f to receiver and params
Language: Kotlin
Variables: fun a value of function type with receiver
Abbreviation: receiver.f(params)

Name: Function literals
Definition: Functions that are not declared but passed immediately as an expression
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Context: Kotlin

Instruction: funName(args) {lambdaExpression}
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Effect: funName(args, lambdaExpression)
Language: Kotlin
Name: trailing lambda

Instruction: funName {lambdaExpression}
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Effect: funName(lambdaExpression)
Language: Kotlin

Instruction: _
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Effect: Unused parameter
Language: Kotlin
Where to use it: In lambda parameters

Instruction: noinline paramName
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Effect: do not inline the lambdas given in this argument
Language: Kotlin
Where to use it: Inline funciton parameters

Question: Restriction on inline arguments
Answer: it can only be sent to other inline arguments, not to noinline arguments
Page: https://kotlinlang.org/docs/lambdas.html#instantiating-a-function-type
Context: Kotlin

Name: non-local return
Definition: A return which do not leave the innermost function/lambda but the innermost fun
Page: https://kotlinlang.org/docs/inline-functions.html#non-local-returns
Context: Kotlin

Instruction: crossinline varName
Page: https://kotlinlang.org/docs/inline-functions.html#non-local-returns
Effect: indicate that varName should be inlined and can be used in other context, such as inside object
Language: Kotlin
Where to use it: parameter

Instruction: reified T
Page: https://kotlinlang.org/docs/inline-functions.html#non-local-returns
Meaning: Introduce a type T, but the type is inlined and can be considered in the actual function body
Language: Kotlin
Where to use it: inlined function typing

Instruction: varName?.let (function)
Page: https://kotlinlang.org/docs/null-safety.html#elvis-operator
Effect: if (varName != null) function(varName)
Language: Kotlin
Variables: varName: TypeName?

Instruction: varName!!
Page: https://kotlinlang.org/docs/null-safety.html#elvis-operator
Effect: Throw an exception if varName is null
Language: Kotlin
Returns: varName as a non-nullable type
Variables: varName: TypeName?

Instruction: this
Page: https://kotlinlang.org/docs/this-expressions.html
Language: Kotlin
Returns: The receiver in the innermost enclosing scope

Instruction: this@label
Page: https://kotlinlang.org/docs/this-expressions.html
Language: Kotlin
Returns: The receiver in the scope label

Instruction: DSL
Page: https://kotlinlang.org/docs/coroutines-overview.html#documentation
Effect: todo
Language: Kotlin

Instruction: annotation class ClassName
Page: https://kotlinlang.org/docs/annotations.html
Effect: Define a class that is an annotation
Language: Kotlin

Question: What are the main differences between read-only collections and mutable collections
Answer: only mutable collection can be mutated
Page: https://kotlinlang.org/docs/collections-overview.html#collection-types
Answer2: Parameter in read-only collection is covariant. E.g. RealOnlyList<ParentClass> is a parent of ReadOnlyList<ChildClass>

Instruction: mutableListOf(
  value_1,
  ...,
  value_n
)
Page: https://kotlinlang.org/docs/collections-overview.html#collection-types
Language: Kotlin
Returns: A mutable list initialized with value_1 ... value_n

Question: What is the default List in Kotlin
Answer: ArrayList
Page: https://kotlinlang.org/docs/collections-overview.html#collection-types
Context: Kotlin

Question: What is the default Set/Map in Kotlin
Answer: LinkedHashSet/Map
Page: https://kotlinlang.org/docs/collections-overview.html#collection-types
Context: Kotlin

Page: https://kotlinlang.org/docs/null-safety.html#safe-calls
Syntactic sugar: expr?.method()
Implementation: if (expr == null)
  expr.method()
else
  null
Language: Kotlin

Page: https://kotlinlang.org/docs/idioms.html
Syntactic sugar: varName ?: defaultValue
Implementation: if
  varName == null
then
  defaultValue
else
  varName
Language: Kotlin

Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Syntactic sugar: val_1 == val_2
Implementation: val_1?.equals(val_2) ?: (val_2 === null)
Language: kotlin

Page: https://kotlinlang.org/docs/basic-types.html#integer-types
Syntactic sugar: val_1 != val_2
Implementation: ! (val_1 == val_2)
Language: kotlin
Index: kt