Skip to content

Instantly share code, notes, and snippets.

@luish
Last active January 22, 2020 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luish/9df84bcf97c2fb99828c65dc5fcef3fa to your computer and use it in GitHub Desktop.
Save luish/9df84bcf97c2fb99828c65dc5fcef3fa to your computer and use it in GitHub Desktop.

Kotlin

  1. Elvis operator
val data = response?.body
val title: String = data?.title ?: 'Page'
  1. Strings templates
print("Response: ${title}")
  1. Attribution
val (a, b, c) = object
  1. When
when (x) {
    0, 1 -> print("x == 0 or x == 1")
    else -> print("otherwise")
}
  1. map
val map = mapOf(1 to "Jan", 2 to "Feb")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment