54 lines
750 B
Markdown
54 lines
750 B
Markdown
# Dropping variables
|
|
Sometimes in Granite, you may want to un-initalise a variable you initialised! This is easy to do.
|
|
|
|
## New operations
|
|
* `:$(variable)`, variable drop, deletes `(variable)`
|
|
|
|
## Tutorial
|
|
Look at this simple program:
|
|
|
|
```
|
|
:?x
|
|
:^x
|
|
:!x
|
|
:?x
|
|
:ax,x,x
|
|
:!x
|
|
```
|
|
|
|
This program is fairly simple, what we expect is that it will prompt the user twice and do some maths on their number!
|
|
|
|
What we _instead_ get is this:
|
|
|
|
```
|
|
? 9
|
|
10
|
|
105
|
|
10
|
|
```
|
|
|
|
This is not very nice looking as it is interpreting the users first input as a prompt.
|
|
|
|
To fix this, use `:$x` after the first print operation to drop the `x` variable!
|
|
|
|
Now your output can look like this:
|
|
|
|
```
|
|
? 9
|
|
10
|
|
? 5
|
|
10
|
|
```
|
|
|
|
Much better!
|
|
|
|
## After example
|
|
```
|
|
:?x
|
|
:^x
|
|
:!x
|
|
:$x
|
|
:?x
|
|
:ax,x,x
|
|
:!x
|
|
```
|