Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

End-Of-Array operator


There is now a shorthand for '<thing-i-am-indexing>.len'

    var a = [1,2,3]
    std.put("last = {}\n", a[$-1])      /* equivalent to a[a.len - 1] */
    std.put("last two = {}\n", a[$-2:]) /* equivalent to a[a.len - 2:] */

The output from this code should be:

    last = 3
    last two = [2, 3]

-- 
    Ori Bernstein