This documentation is for not yet released version of ytt. For the documentation of the latest release version, see the latest version.
Lists
#@ nums = [123, 374, 490]
first: #@ nums[0]
Copied here for convenience from Starlark specification.
- list·append (
L.append(x)
)
x = []
x.append(1) # None
x.append(2) # None
x.append(3) # None
x # [1, 2, 3]
- list·clear (
L.clear()
)
x = [1, 2, 3]
x.clear() # None
x # []
- list·extend (
L.extend(x)
)
x = []
x.extend([1, 2, 3]) # None
x.extend(["foo"]) # None
x # [1, 2, 3, "foo"]
- list·index (
L.index(x[, start[, end]])
)
x = list("banana".codepoints())
x.index("a") # 1 (bAnana)
x.index("a", 2) # 3 (banAna)
x.index("a", -2) # 5 (bananA)
- list·insert (
L.insert(i, x)
)
x = ["b", "c", "e"]
x.insert(0, "a") # None
x.insert(-1, "d") # None
x # ["a", "b", "c", "d", "e"]
- list·pop (
L.pop([index])
) - list·remove (
L.remove(x)
)
x = [1, 2, 3, 2]
x.remove(2) # None (x == [1, 3, 2])
x.remove(2) # None (x == [1, 3])
x.remove(2) # error: element not found
(Help improve our docs: edit this page on GitHub)