Created
March 7, 2018 00:30
-
-
Save tasaquino/228ad86c3ede38b1a07291e5f42a4248 to your computer and use it in GitHub Desktop.
Kotlin - When with enum example
This file contains 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 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