capitalize

Common
JVM
JS
Native
1.0
fun String.capitalize(): String
For JVM

Returns a copy of this string having its first letter uppercased, or the original string, if it's empty or already starts with an upper case letter.

import kotlin.test.assertTrue

fun main(args: Array<String>) {
//sampleStart
println("abcd".capitalize()) // Abcd
println("Abcd".capitalize()) // Abcd
//sampleEnd
}
For JS

Returns a copy of this string capitalised if it is not empty or already starting with an uppper case letter, otherwise returns this

IncludeFunctionBody ../../test/StringTest.kt capitalize

For Native

Returns a copy of this string having its first letter uppercased, or the original string, if it's empty or already starts with an upper case letter.



fun main(args: Array<String>) {
//sampleStart
//Unresolved: samples.text.Strings.captialize
//sampleEnd
}