replaceFirstChar

@JvmName(name = "replaceFirstCharWithChar")
inline fun String.replaceFirstChar(transform: (Char) -> Char): String(source)
@JvmName(name = "replaceFirstCharWithCharSequence")
inline fun String.replaceFirstChar(transform: (Char) -> CharSequence): String(source)

Returns a copy of this string having its first character replaced with the result of the specified transform, or the original string if it's empty.

Since Kotlin

1.5

Parameters

transform

function that takes the first character and returns the result of the transform applied to the character.

Samples