Rewrite of text and examples.
This commit is contained in:
parent
8de6605112
commit
3b8ae69a6c
@ -1,34 +1,34 @@
|
||||
# Assignment Operator
|
||||
|
||||
Set the value for local and global variables.
|
||||
Use an equals sign to make a [variable](/reference/variables/var) store the [number](/reference/types/number)
|
||||
or [string](/reference/types/string) you say.
|
||||
|
||||
### @parent blocks/operators
|
||||
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*.
|
||||
|
||||
Set or change the value of a variable
|
||||
### Storing numbers in variables
|
||||
|
||||
This program makes the variable `item` equal `5` and then shows it on the [LED screen](/device/screen).
|
||||
|
||||
````blocks
|
||||
let item = 0
|
||||
let item = 5
|
||||
basic.showNumber(item)
|
||||
````
|
||||
|
||||
Use the assignment operator to set or change the value of a [variable](/reference/variables/var).
|
||||
### Storing strings in variables
|
||||
|
||||
### Declare a variable
|
||||
|
||||
Declare a new *local* variable using the [variable](/reference/variables/var) statement and the assignment operator. Like this:
|
||||
This program makes the variable `name` equal `Joe` and then shows it on the [LED screen](/device/screen).
|
||||
|
||||
````blocks
|
||||
let num1 = 42;
|
||||
let name = "Joe";
|
||||
let name = "Joe"
|
||||
basic.showString(name);
|
||||
````
|
||||
|
||||
The variable's name is on the left of the assignment operator and the variable's value is on the right:
|
||||
|
||||
````blocks
|
||||
let num1 = 42
|
||||
````
|
||||
### Notes
|
||||
|
||||
* You can use the assignment operator with variables of each of the supported [types](/reference/types).
|
||||
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.
|
||||
|
||||
### Lessons
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user