Skip to content

Instantly share code, notes, and snippets.

@kmdsbng
Created November 23, 2019 13:12
Show Gist options
  • Save kmdsbng/8feef9db47cf65a2d730d527bc4b9eb2 to your computer and use it in GitHub Desktop.
Save kmdsbng/8feef9db47cf65a2d730d527bc4b9eb2 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 booBoos : List<BooBoo> = chars.shuffled().withIndex().map { (index, char) ->
if (index > 1) {
Choon(char)
} else {
Tanon(char)
}
}
println(booBoos.map {it.sayBoo()}.joinToString(""))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment