Skip to content

Instantly share code, notes, and snippets.

@sajjadyousefnia
Created May 3, 2018 07:22
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/bfc9be261b4e4106f02b90fed810ce1b to your computer and use it in GitHub Desktop.
Save sajjadyousefnia/bfc9be261b4e4106f02b90fed810ce1b to your computer and use it in GitHub Desktop.
fun getUserNameAndState(id: Int): Pair<String?, String?> {
require(id > 0, { "Error: 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]
return Pair(userName, userState)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment