Strings

Ki has two string types: string and dynstring, corresponding to array and dynarray; indeed, string and dynstring are essentially array and dynarray, thus iterating over them yields a sequence of rune values. Of course, they also have some extra features that array and dynarray don't. String literals in Ki, like "русский автор", are encoded in UTF-8.

fn xform(string s): <string> {
    return "Behold, I am transformed!"
}

fn main() {
    val a: "This is a string"
    val b: "This is a "
           "multiline string"
    val c: "This is how you interpolate values: ${a}"
    val d: `This string will not decode special characters or `
           `interpolate other values, like ${a}\n`
    val e: "This is how you transform an interpolated value: ${xform(a)}"
}
fn main() {
    val s: "apple"
    val vowels: "aeiouy"

    echo("Vowels in ${s}:")

    for (r in s) {
        if (r in vowels) {
            echo("\t${c}")
        }
    }
}
fn main() {
    var s: "apple"

    with (s[4]) {
        s[4] = 'y'
    }
}

Strings are indexable, but as they are displayed as encoded in UTF-8, this may yield surprising results. Use with care.