Contents

insert(_:at:)

Inserts into the receiver the characters of a given string at a given location.

Declaration

func insert(_ aString: String, at loc: Int)

Parameters

  • aString:

    The string to insert into the receiver. aString must not be nil.

  • loc:

    The location at which aString is inserted. The location must not exceed the bounds of the receiver.

Discussion

The new characters begin at loc and the existing characters from loc to the end are shifted by the length of aString.

This method treats the length of the string as a valid index value that returns an empty string.

See Also

Modifying a String