# Data: lists and objects

A variable holds a value: a number, text in quotes, `true` / `false`, a list `[…]` or an object
`{ … }`.

```vi
score = 0
player = "Ada"
playing = true
scores = [12, 40, 7]
user = { name: "Sam", age: 31 }

main show_data():
  scores.add(25)
  print(player, "has", scores.count, "scores")
  print("first", scores.first, "last", scores.last)
  print("has 40?", scores.has(40))
  user.age = user.age + 1
  print(user.name, "is now", user.age)
  scores.remove(7)
  print(scores)
  scores.clear()
  print("left:", scores.count)
```

| On a list | Does |
|---|---|
| `items.add(x)` | adds `x` at the end |
| `items.remove(x)` | removes `x` |
| `items.clear()` | removes everything |
| `items.count` | how many there are |
| `items.first`, `items.last` | the first and the last |
| `items.has(x)` | `true` when `x` is in the list |
| `items.index(x)` | where `x` is (from 0) |
| `items[0]` | the item at a place, from 0 |

Objects group named values: `user.name` reads one, `user.age = 32` changes it. A list of objects is
the usual way to hold records: `tasks = [{ name: "Milk", done: false }]`.
