[lang-ref] ( titlize ) ( kotlin )
@Disabled("Not supported")
@Test
fun titlize() {
}
@Test
fun titlizeAlternative() {
val s = "abc def ghi"
val titled = s
.split(" ")
.joinToString(" ") { word ->
if (word.isEmpty()) {
word
} else {
word.replaceFirstChar { c ->
if (c.isLowerCase()) {
c.titlecase()
} else {
c.toString()
}
}
}
}
assertEquals("Abc Def Ghi", titled)
}