Collections & Maps

Collections

Fahrenheit provides specialized collection types: Stack, Queue, and List.

Stack

A Last-In-First-Out (LIFO) data structure.

Queue

A First-In-First-Out (FIFO) data structure.

List

A dynamic list, currently implemented as an alias for standard Fahrenheit Arrays.

Maps

Maps are key-value data structures defined using the map keyword.

Definition


myMap = map {
    "key1": "value1",
    "key2": 100,
    "nested": map { "x": 1 }
};
    

Accessing Values


val = myMap["key1"];
val2 = myMap.key2;
    

Modifying Values


myMap["key1"] = "New Value";
myMap.newKey = 500;
    

Iteration


foreach (k : myMap) {
    print(k + " -> " + myMap[k]);
}