Skip to content

Instantly share code, notes, and snippets.

@sajjadyousefnia
Created May 3, 2018 12:28
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 sajjadyousefnia/523c1a1244ba13a31e0063fab18f6dae to your computer and use it in GitHub Desktop.
Save sajjadyousefnia/523c1a1244ba13a31e0063fab18f6dae to your computer and use it in GitHub Desktop.
fun getUserNameStateAndAge(id: Int): Triple<String?, String?, Int> {
require(id > 0, { "id is less than 0" })
val userNames: Map<Int, String> = mapOf(101 to "Chike", 102 to "Segun", 104 to "Jane")
val userStates: Map<Int, String> = mapOf(101 to "Lagos", 102 to "Imo", 104 to "Enugu")
val userName = userNames[id]
val userState = userStates[id]
val userAge = 6
return Triple(userNames[id], userStates[id], userAge)
}
val (name, state, age) = getUserNameStateAndAge(101)
println(name) // Chike
println(state) // Lagos
println(age) // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment