Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 2.3 KB

misc.md

File metadata and controls

59 lines (44 loc) · 2.3 KB

Module

is a set of Kotlin files compiled together.

Function type "(A.(B) -> C)"

Kotlin.Result

Interoperability between Kotlin and Java

Java sees functions defined in Kotlin only through bytecode.

Int.MAX_VALUE

  • 10^9 (1,000,000,000) < Int.MAX_VALUE (2,147,483,647) < 10^10 < (10,000,000,000)
  • This knowledge is necessary in competitive programming

Declaration-site variance

  • Invariant
    • is a type parameter without the "in" or "out" modifier.
    • If a type parameter is invariant, the exact same type is required.
  • Covariant
    • is a type parameter with the "out" modifier.
    • can only be returned (produced) and never referenced (consumed).
    • can return a subtype.
      • Producer
      • If a signature of a function is supposed to return a Dog, it can return a Pug but not an Animal.
  • Contravariant
    • is a type parameter with the "in" modifier.
    • can only be referenced (consumed) and never returned (produced).
    • can receive a subtype.
      • Consumer
      • If a signature of a function is supposed to receive a Dog, it can receive a Pug but not an Animal.
  • https://kotlinlang.org/docs/reference/generics.html#declaration-site-variance

@Volatile

is normally used in a database instance.

@Volatile
private var INSTANCE: MyDatabase? = null