Skip to content

Instantly share code, notes, and snippets.

@kmdsbng
Last active November 23, 2019 13:30
Show Gist options
  • Save kmdsbng/075d5fd9c8f5c61c6c18fae00368cc5c to your computer and use it in GitHub Desktop.
Save kmdsbng/075d5fd9c8f5c61c6c18fae00368cc5c to your computer and use it in GitHub Desktop.
interface BooBoo {
fun sayBoo(): String
}
data class Tanon(val char: String) : BooBoo {
override fun sayBoo(): String = char
}
data class Choon(val char: String) : BooBoo {
override fun sayBoo(): String = char + "ー"
}
fun main() {
val chars = listOf("ボ", "ジョ", "レ", "ヌ", "ボ")
val shuffled = chars.shuffled()
val tanons = shuffled.take(2).map {Tanon(it)}
val choons = shuffled.drop(2).map {Choon(it)}
val booBoos = tanons + choons
println(booBoos.map {it.sayBoo()}.joinToString(""))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment