Skip to content

Instantly share code, notes, and snippets.

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