The Equals Sign

## Introduction

The "equals" sign is a way to make single-item lists easier to write.

```
veg1 = {celery|spinach}
veg2
  {celery|spinach}

```

It's easier and neater to have things like this in one line, like we've done with `veg1`. But it's time to talk about some important differences between these two ways of writing a "single-item list".

## Differences

### `selectOne` at a List

Firstly, what happens when we write `[v = veg2.selectOne]`? What gets stored in `v`? What gets output by the square block?

Well, remember that `selectOne` is just a special command that selects one item from the list. And we can see that `veg2` only has one item: `{celery|spinach}`, so `veg2.selectOne` will always result in `{celery|spinach}`. That's what will get stored in `v`. So, whenever we write `[v]`, we'll get either "celery" or "spinach" with a 50% probability each.

A **common rookie mistake** here is to think that either "celery" or "spinach" would be stored in `v`, but that's not how `selectOne` works. It just selects a random item from your list - it doesn't "evaluate" that item to produce "plain" text like "celery" or "spinach". That's why `[v]` randomly outputs either "celery" or "spinach" each time, instead of always outputting the same one.

Now, remember, when we assign a value to a variable in a square block (like so: `[v = veg2.selectOne]`), that value will also be *outputted* by the block. So the block will output `{celery|spinach}` (the value we stored in `v`).

Before displaying the output of a square block on the page, Perchance *always fully evaluates it* so that it's just plain text (no square or curly brackets). So the block outputs `{celery|spinach}`, and then Perchance randomly evaluates it into either "celery" or "spinach" before displaying it on the page. So we know that our block, `[v = veg2.selectOne]`, will output either "celery" or "spinach", and that we've stored `{celery|spinach}` in `v`.

### `selectOne` at a Equals Sign

Okay, now let's look at `veg1` and how it differs. `veg1` is actually a *direct reference* to `{celery|spinach}`. It's not a list. So when we write `veg1.selectOne`, we're applying `selectOne` directly to `{celery|spinach}`, which is an inline list. So `veg1.selectOne` will result in either "celery" or "spinach", each with equal likelihood. So if you write `[v = veg1.selectOne]`, then `v` contains *either* "celery" **or** "spinach".

So, in the example below, can you predict what `output1` and `output2` will look like?

```
veg1 = {celery|spinach}
veg2
  {celery|spinach}

output1
  [v = veg1.selectOne] [v] [v] [v]
output2
  [v = veg2.selectOne] [v] [v] [v]

```

The answer is that `output1` will be either "celery celery celery celery" or "spinach spinach spinach spinach", whereas `output2` will be something like "celery spinach spinach celery" or "spinach spinach celery spinach" - i.e. `v` in `output2` contains `{celery|spinach}` so it'll be random each time, whereas in `output1`, `v` either contains "celery" **or** "spinach".

The key understanding here is that `veg1` *isn't actually a list* at all. It's a direct reference to `{celery|spinach}`. So in this case `veg1` is basically equivalent to `veg2.selectOne` since they both refer to `{celery|spinach}`

You don't need to worry about the difference between these two cases if you're not using `selectOne` and assigning the result to a variable (like `v` in the above examples. That's because Perchance will always fully evaluate [veg1] and [veg2] into either "celery" or "spinach" if you just write them in a square block like that.

What if you had a list like `veg2` but you wanted to store either "celery" or "spinach" in `v` instead of storing `{celery|spinach}`? In that case you can just write `[v = veg2.selectOne.selectOne]`.