Skip to content

Instantly share code, notes, and snippets.

@ch8n
Last active July 31, 2019 11:40
Show Gist options
  • Save ch8n/35bd042e1bc5d46e6f04ea1e4b7313bf to your computer and use it in GitHub Desktop.
Save ch8n/35bd042e1bc5d46e6f04ea1e4b7313bf to your computer and use it in GitHub Desktop.
return types destrcuturing
// Destructuring declarations can also be used when working with return values:
fun getPerson() = Person("ch8n", 25)
val(name, age) = getPerson()
//Or let’s say we need to return two values from a function:
fun getInfo(): Pair<Int, String> = Pair("ch8n", 25)
val (name, age) = twoValuesReturn()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment