Finding an item by its position

Syntax and values

An index tells Pliro which item you want. List and text positions start at zero, so the first item has index 0.

let scores = [10, 20, 30]
let empty = []
let mixed = [1, "two", true, none]

Lists preserve order and may contain any value. A trailing comma is accepted.
Indexes are zero-based, non-negative whole numbers:

say scores[0]
set scores[1] = 25

An index must already be in range. Lists have fixed length because there is no
append operation in the current standard library. left + right creates a new
concatenated list.

Text supports zero-based read-only indexing by Unicode code point:

let mascot = "🐢Pliro"
say mascot[0]  # 🐢

Text cannot be changed through set.

Example

# language: en
let items = [10, 20]
say items[0]
say "🐢ab"[0]
let player = {"score": 12}
say player["score"]

Syntax and values · Built-ins · Programming guides