Skip to content

Instantly share code, notes, and snippets.

@tasaquino
Last active March 6, 2018 22:30
Show Gist options
  • Save tasaquino/07d6ec1f4c1314b006bbb9f063eeb79b to your computer and use it in GitHub Desktop.
Save tasaquino/07d6ec1f4c1314b006bbb9f063eeb79b to your computer and use it in GitHub Desktop.
Kotlin - Enum with functions Example
enum class House(val words:String) {
BARATHEON("Ours Is the Fury"),
BOLTON("Our Blades Are Sharp"),
LANNISTER("A Lannister Always Pays His Debts"),
MARTELL("Unbowed, Unbent, Unbroken"),
STARK("Winter Is Coming"),
TARGARYEN("Fire and Blood"),
TULLY("Family, Duty, Honor");
fun sayWords() = "Words: $words"
}
fun main(args: Array<String>) {
println(House.STARK.sayWords())
// Words: Winter Is Coming
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment