klyn.MutableString._sliceAssign
method
public static _sliceAssign(text as String, start as Long, stop as Long, sliceStep as Long, hasStart as Boolean, hasStop as Boolean, replacement as String) as String
Description

Internal helper used by the compiler to implement string slice assignment.

Slice assignment can change the number of characters. This helper returns a new immutable backing value which the compiler stores in the existing MutableString object. Aliases observe the edit; earlier String snapshots remain unchanged. The backing value is published only after success.

Parameters
ParameterDescription
textSource string.
startRequested start bound.
stopRequested exclusive stop bound.
sliceStepSlice step. Cannot be zero.
hasStartTrue when the source slice explicitly provided a start.
hasStopTrue when the source slice explicitly provided a stop.
replacementReplacement text.
Returns

A new string with the requested slice replaced.

Throws
  • Exception if sliceStep == 0.
  • ValueException if an extended slice replacement has the wrong length.
Example
value = m"Hello World"
value[6:11] = "Klyn!"
assert value == "Hello Klyn!"