Created
May 3, 2018 12:28
-
-
Save sajjadyousefnia/523c1a1244ba13a31e0063fab18f6dae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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