Capitalize the each words in sentence of kotlin (Capitalize method getting deprecated)
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
fun main(args: Array<String>) { | |
/* Capitalize first letter | |
in each word*/ | |
val str = "kotlin is programing language" | |
val words = str.split(" ") | |
val result = words.map { | |
it.replaceFirstChar { | |
it.uppercase() | |
} | |
} | |
println(result.joinToString(" ")) | |
} |
Comments
Post a Comment