klyn.String._sliceAssign
method

    public static _sliceAssign(text as String, start as Int, stop as Int, sliceStep as Int, hasStart as Boolean, hasStop as Boolean, replacement as String) as String:

Description

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

The helper returns a new string because Klyn strings are represented by an immutable runtime buffer. The compiler stores that returned value back into the assignable target (`text[a:b] = replacement`).

Parameters

Parameter | Description
--- | ---
`text` | Source string.
`start` | Requested start bound.
`stop` | Requested exclusive stop bound.
`sliceStep` | Slice step. Cannot be zero.
`hasStart` | True when the source slice explicitly provided a start.
`hasStop` | True when the source slice explicitly provided a stop.
`replacement` | Replacement 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 = String._sliceAssign("Hello World", 6, 11, 1, true, true, "Klyn!")
    assert value == "Hello Klyn!"