granite-docs/docs/dropping-variables.md
2024-08-16 14:48:06 +01:00

750 B

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