2016-03-26 00:47:20 +01:00
|
|
|
# Assignment Operator
|
|
|
|
|
2016-05-25 00:36:04 +02:00
|
|
|
Use an equals sign to make a [variable](/reference/variables/var) store the [number](/reference/types/number)
|
|
|
|
or [string](/reference/types/string) you say.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-05-25 00:36:04 +02:00
|
|
|
When you use the equals sign to store something in a variable, the equals sign is called
|
|
|
|
an *assignment operator*, and what you store is called a *value*.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-05-25 00:36:04 +02:00
|
|
|
### Storing numbers in variables
|
|
|
|
|
|
|
|
This program makes the variable `item` equal `5` and then shows it on the [LED screen](/device/screen).
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
````blocks
|
2016-05-25 00:36:04 +02:00
|
|
|
let item = 5
|
|
|
|
basic.showNumber(item)
|
2016-03-26 00:47:20 +01:00
|
|
|
````
|
|
|
|
|
2016-05-25 00:36:04 +02:00
|
|
|
### Storing strings in variables
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-05-25 00:36:04 +02:00
|
|
|
This program makes the variable `name` equal `Joe` and then shows it on the [LED screen](/device/screen).
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
````blocks
|
2016-05-25 00:36:04 +02:00
|
|
|
let name = "Joe"
|
|
|
|
basic.showString(name);
|
2016-03-26 00:47:20 +01:00
|
|
|
````
|
|
|
|
|
|
|
|
### Notes
|
|
|
|
|
2016-05-25 00:36:04 +02:00
|
|
|
You can use the assignment operator with variables of
|
|
|
|
every [type](/reference/types). A *type* is which kind of thing
|
|
|
|
a variable can store, like a number or string.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
### See also
|
|
|
|
|
2016-04-18 17:33:09 +02:00
|
|
|
[variable](/reference/variables/var), [types](/reference/types)
|
2016-03-26 00:47:20 +01:00
|
|
|
|