Core API – Kotlin Programming Language (original) (raw)
decapitalize
Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase() }Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.
Since Kotlin
1.0
Samples
import kotlin.test.*
fun main() {
//sampleStart
println("abcd".decapitalize()) // abcd
println("Abcd".decapitalize()) // abcd
//sampleEnd
}Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase() }Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.
Since Kotlin
1.1
Samples
import kotlin.test.*
fun main() {
//sampleStart
println("abcd".decapitalize()) // abcd
println("Abcd".decapitalize()) // abcd
//sampleEnd
}Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase(locale) }Returns a copy of this string having its first letter lowercased using the rules of the specified locale, or the original string, if it's empty or already starts with a lower case letter.
Since Kotlin
1.4
Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase(Locale.getDefault()) }Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.
Since Kotlin
1.0
Samples
import kotlin.test.*
fun main() {
//sampleStart
println("abcd".decapitalize()) // abcd
println("Abcd".decapitalize()) // abcd
//sampleEnd
}Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase() }Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.
Since Kotlin
1.3
Samples
import kotlin.test.*
fun main() {
//sampleStart
println("abcd".decapitalize()) // abcd
println("Abcd".decapitalize()) // abcd
//sampleEnd
}Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase() }Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.
Since Kotlin
1.8
Samples
import kotlin.test.*
fun main() {
//sampleStart
println("abcd".decapitalize()) // abcd
println("Abcd".decapitalize()) // abcd
//sampleEnd
}Deprecated
Warning since 1.5
Use replaceFirstChar instead.
Replace with
replaceFirstChar { it.lowercase() }Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.
Since Kotlin
1.8
Samples
import kotlin.test.*
fun main() {
//sampleStart
println("abcd".decapitalize()) // abcd
println("Abcd".decapitalize()) // abcd
//sampleEnd
}