Getting and setting list values

The following verbose code sets and gets String values from a list by using the native Java ArrayList class.

var strs = new ArrayList<String>(){"a", "ab", "abc"}
strs.set(0, "b")
var firstStr = strs.get(0)

You can write this code in Gosu in more natural index syntax using Gosu shortcuts.

var strs = {"a", "ab", "abc"}
strs[0] = "b"
var firstStr = strs[0]

This Gosu syntax does not automatically resize lists. If a list has only three items, the following code fails at run time with an index out of bounds exception.

strs[3] = "b" // Index number 2 is the higest supported number