insert

Platform and version requirements: JS (1.3), Native (1.3)
fun insert(index: Int, value: Boolean): StringBuilder

Inserts the string representation of the specified boolean value into this string builder at the specified index and returns this instance.

The overall effect is exactly as if the value were converted to a string by the value.toString() method, and then that string was inserted into this string builder at the specified index.

Exceptions

IndexOutOfBoundsException - if index is less than zero or greater than the length of this string builder.

Platform and version requirements: JS (1.3), Native (1.3)
fun insert(index: Int, value: Char): StringBuilder

Inserts the specified character value into this string builder at the specified index and returns this instance.

Exceptions

IndexOutOfBoundsException - if index is less than zero or greater than the length of this string builder.

Platform and version requirements: JS (1.3), Native (1.3)
fun insert(index: Int, value: CharArray): StringBuilder

Inserts characters in the specified character array value into this string builder at the specified index and returns this instance.

The inserted characters go in same order as in the value character array, starting at index.

Exceptions

IndexOutOfBoundsException - if index is less than zero or greater than the length of this string builder.

Platform and version requirements: JS (1.3), Native (1.3)
fun insert(index: Int, value: CharSequence?): StringBuilder

Inserts characters in the specified character sequence value into this string builder at the specified index and returns this instance.

The inserted characters go in the same order as in the value character sequence, starting at index.

Parameters

index - the position in this string builder to insert at.

value - the character sequence from which characters are inserted. If value is null, then the four characters "null" are inserted.

Exceptions

IndexOutOfBoundsException - if index is less than zero or greater than the length of this string builder.

Platform and version requirements: JS (1.3), Native (1.3)
fun insert(index: Int, value: Any?): StringBuilder

Inserts the string representation of the specified object value into this string builder at the specified index and returns this instance.

The overall effect is exactly as if the value were converted to a string by the value.toString() method, and then that string was inserted into this string builder at the specified index.

Exceptions

IndexOutOfBoundsException - if index is less than zero or greater than the length of this string builder.

Platform and version requirements: JS (1.3), Native (1.3)
fun insert(index: Int, value: String?): StringBuilder

Inserts the string value into this string builder at the specified index and returns this instance.

If value is null, then the four characters "null" are inserted.

Exceptions

IndexOutOfBoundsException - if index is less than zero or greater than the length of this string builder.

Platform and version requirements: JS (1.1), Native (1.1)
fun insert(index: Int, value: String): StringBuilder
Deprecated: Provided for binary compatibility.
Platform and version requirements: Native (1.3)
fun insert(index: Int, value: Byte): StringBuilder
fun insert(index: Int, value: Short): StringBuilder
fun insert(index: Int, value: Int): StringBuilder
fun insert(index: Int, value: Long): StringBuilder
fun insert(index: Int, value: Float): StringBuilder
fun insert(index: Int, value: Double): StringBuilder

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-string-builder/insert.html