Created
March 7, 2018 00:19
-
-
Save tasaquino/24775d22221bcde8bc730cdf88f0d75c to your computer and use it in GitHub Desktop.
Kotlin - Enum inherit from interface 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
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