Variables

Variables (vars) are places in memory when we store a values

Variables in Green Tea are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

Variable names follow the same rules as other labels in GreenTea. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$

Ex: $var_name

Assignment

Put a value into a var

$var:<value>

Ex:

$name:John

$age:24

Or assigning multiple vars at ocne:

$name,$age: John, 24

Get value

To get a variable’s value, use it’s name:

$name:John

$name

> John

Scope

A variable defined in a function only usable in that function.

If you want to access global variables inside function, use $$ instead of $

$a=0

@function

$b: 1

$$c: 2

@echo $a // error

@echo $$a // output: 0

@echo $b // error

@echo $c // output: 2