Getting Started
Installation
Usage
Basic Syntax
Data Types
Expressions
Variables
Conditions
Commands
Arrays
Loops
Functions
Importing
Advanced Syntax
As Cast
Builtins
Type Condition
Compiler Flags
Standard Library
Array
Date
Environment
FileSystem
HTTP
Math
Text
Contributing
How to
Guide
Compiler structure
Amber by Example
ShellCheck tester
Ubuntu Updater
Bot Detector
LSP Installer
Variables
Variables are the way to store values we discussed earlier. In order to create a variable you can use a let
keyword. Here is an example:
let name = "John"
The above example shows how to initialize a variable. However if you have already created the one you want, you can reassign it just by name (without using any keywords)
name = "Rob"
And to access the value stored by this variable - just refer to it by name, like so:
echo name // Outputs: "Rob"
Overshadowing
Variable declarations can be overshadowed - this means that you can redeclare the existing variable with different data type in given scope if you need to. Here is an example:
// `result` is a `Num`
let result = 123
// `result` is a `Text`
let result = "Hello my friend"
Reserved Prefix
The Amber compiler reserves all identifiers starting with double underscore __
in addition to keywords like let
, if
, etc.
Getting Started
Installation
Usage
Basic Syntax
Data Types
Expressions
Variables
Conditions
Commands
Arrays
Loops
Functions
Importing
Advanced Syntax
As Cast
Builtins
Type Condition
Compiler Flags
Standard Library
Array
Date
Environment
FileSystem
HTTP
Math
Text
Contributing
How to
Guide
Compiler structure
Amber by Example
ShellCheck tester
Ubuntu Updater
Bot Detector
LSP Installer