toCharArray

Returns a CharArray containing characters of this string.

Since Kotlin

1.4

expect fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray(source)

Returns a CharArray containing characters of this string or its substring.

Since Kotlin

1.4

Parameters

startIndex

the beginning (inclusive) of the substring, 0 by default.

endIndex

the end (exclusive) of the substring, length of this string by default.

Throws

if startIndex is less than zero or endIndex is greater than the length of this string.


expect fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)(source)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.4

Parameters

destination

the array to copy to.

destinationOffset

the position in the array to copy to, 0 by default.

startIndex

the beginning (inclusive) of the range to copy, 0 by default.

endIndex

the end (exclusive) of the range to copy, length of this string builder by default.

Throws

when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

Returns a CharArray containing characters of this string.

Since Kotlin

1.4

actual fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray(source)

Returns a CharArray containing characters of this string or its substring.

Since Kotlin

1.4

Parameters

startIndex

the beginning (inclusive) of the substring, 0 by default.

endIndex

the end (exclusive) of the substring, length of this string by default.

Throws

if startIndex is less than zero or endIndex is greater than the length of this string.


actual inline fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)(source)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.4

Parameters

destination

the array to copy to.

destinationOffset

the position in the array to copy to, 0 by default.

startIndex

the beginning (inclusive) of the range to copy, 0 by default.

endIndex

the end (exclusive) of the range to copy, length of this string builder by default.

Throws

when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

inline fun String.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = length): CharArray(source)

Copies characters from this string into the destination character array and returns that array.

Since Kotlin

1.0

Parameters

destination

the array to copy to.

destinationOffset

the position in the array to copy to.

startIndex

the start offset (inclusive) of the substring to copy.

endIndex

the end offset (exclusive) of the substring to copy.


actual inline fun String.toCharArray(): CharArray(source)

Returns a CharArray containing characters of this string.

Since Kotlin

1.0

actual fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray(source)

Returns a CharArray containing characters of this string or its substring.

Since Kotlin

1.4

Parameters

startIndex

the beginning (inclusive) of the substring, 0 by default.

endIndex

the end (exclusive) of the substring, length of this string by default.

Throws

if startIndex is less than zero or endIndex is greater than the length of this string.

Returns a CharArray containing characters of this string.

Since Kotlin

1.3

actual fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray(source)

Returns a CharArray containing characters of this string or its substring.

Since Kotlin

1.3

Parameters

startIndex

the beginning (inclusive) of the substring, 0 by default.

endIndex

the end (exclusive) of the substring, length of this string by default.

Throws

if startIndex is less than zero or endIndex is greater than the length of this string.


actual inline fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)(source)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.4

Parameters

destination

the array to copy to.

destinationOffset

the position in the array to copy to, 0 by default.

startIndex

the beginning (inclusive) of the range to copy, 0 by default.

endIndex

the end (exclusive) of the range to copy, length of this string builder by default.

Throws

when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

Returns a CharArray containing characters of this string.

Since Kotlin

1.8

actual fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray(source)

Returns a CharArray containing characters of this string or its substring.

Since Kotlin

1.8

Parameters

startIndex

the beginning (inclusive) of the substring, 0 by default.

endIndex

the end (exclusive) of the substring, length of this string by default.

Throws

if startIndex is less than zero or endIndex is greater than the length of this string.


actual inline fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)(source)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.8

Parameters

destination

the array to copy to.

destinationOffset

the position in the array to copy to, 0 by default.

startIndex

the beginning (inclusive) of the range to copy, 0 by default.

endIndex

the end (exclusive) of the range to copy, length of this string builder by default.

Throws

when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

Returns a CharArray containing characters of this string.

Since Kotlin

1.8

actual fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray(source)

Returns a CharArray containing characters of this string or its substring.

Since Kotlin

1.8

Parameters

startIndex

the beginning (inclusive) of the substring, 0 by default.

endIndex

the end (exclusive) of the substring, length of this string by default.

Throws

if startIndex is less than zero or endIndex is greater than the length of this string.


actual inline fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)(source)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.8

Parameters

destination

the array to copy to.

destinationOffset

the position in the array to copy to, 0 by default.

startIndex

the beginning (inclusive) of the range to copy, 0 by default.

endIndex

the end (exclusive) of the range to copy, length of this string builder by default.

Throws

when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.