1# Variables 2 3The `let` builtin is used to create local variables within the shell, and apply basic arithmetic 4to variables. The `export` keyword may be used to do the same for the creation of external 5variables. Variables cannot be created the POSIX way, as the POSIX way is awkard to read/write 6and parse. 7 8```sh 9let string_variable = "hello string" 10let array_variable = [ hello array ] 11``` 12 13## Multiple Assignments 14 15Ion also supports setting multiple values at the same time 16 17```sh 18let a b = one two 19echo $a 20echo $b 21 22let a b = one [two three four] 23echo $a 24echo @b 25``` 26 27#### Output 28 29``` 30one 31two 32one 33two three four 34``` 35 36## Type-Checked Assignments 37 38It's also possible to designate the type that a variable is allowed to be initialized with. 39Boolean type assignments will also normalize inputs into either `true` or `false`. When an 40invalid value is supplied, the assignment operation will fail and an error message will be 41printed. All assignments after the failed assignment will be ignored. 42 43```sh 44let a:bool = 1 45let b:bool = true 46let c:bool = n 47echo $a $b $c 48 49 50let a:str b[str] c:int d:float[] = one [two three] 4 [5.1 6.2 7.3] 51echo $a 52echo @b 53echo $c 54echo @d 55``` 56 57#### Output 58 59``` 60true 61true 62false 63one 64two three 654 665.1 6.2 7.3 67``` 68 69## Dropping Variables 70 71Variables may be dropped from a scope with the `drop` keyword. Considering that a variable 72can only be assigned to one type at a time, this will drop whichever value is assigned to 73that type. 74 75``` 76let string = "hello" 77drop string 78let array = [ hello world ] 79drop array 80``` 81 82## Supported Primitive Types 83 84- `str`: A string, the essential primitive of a shell. 85- `bool`: A value which is either `true` or `false`. 86- `int`: An integer is any whole number. 87- `float`: A float is a rational number (fractions represented as a decimal). 88 89## Arrays 90 91The `[T]` type, where `T` is a primitive, is an array of that primitive type. 92 93## Maps 94 95Likewise, `hmap[T]` and `bmap[T]` work in a similar fashion, but are a collection 96of key/value pairs, where the key is always a `str`, and the value is defined by the 97`T`. 98