Skip to content

Instantly share code, notes, and snippets.

@tasaquino
Created March 7, 2018 00:30
Show Gist options
  • Save tasaquino/228ad86c3ede38b1a07291e5f42a4248 to your computer and use it in GitHub Desktop.
Save tasaquino/228ad86c3ede38b1a07291e5f42a4248 to your computer and use it in GitHub Desktop.
Kotlin - When with enum example
fun showWordsOfHouse(house: House) =
when (house) {
House.BARATHEON -> "Ours Is the Fury"
House.BOLTON -> "Our Blades Are Sharp"
House.LANNISTER -> "A Lannister Always Pays His Debts"
House.MARTELL -> "Unbowed, Unbent, Unbroken"
House.STARK -> "Winter Is Coming"
House.TARGARYEN -> "Fire and Blood"
House.TULLY -> "Family, Duty, Honor"
}
fun main(args: Array<String>) {
println(showWordsOfHouse(House.LANNISTER))
// A Lannister Always Pays His Debts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment