Last active
August 29, 2015 14:22
-
-
Save pardom-zz/5040aeac4a591950ef9c to your computer and use it in GitHub Desktop.
Kotlin Hello World
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
package hello | |
import hello.Language.* | |
enum class Language(val greeting: String) { | |
EN("Hello"), ES("Hola"), FR("Bonjour") | |
} | |
open class Person(var name: String, var lang: Language = EN) { | |
fun greet() = println("${lang.greeting}, $name!") | |
} | |
class Hispanophone(name: String) : Person(name, ES) | |
class Francophone(name: String) : Person(name, FR) | |
fun main(args: Array<String>) { | |
listOf( | |
Person("Michael"), | |
Hispanophone("Miguel"), | |
Francophone("Michelle") | |
).forEach { it.greet() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment