API Reference
Classes 
Map 
Immutable Map.
Methods 
| Name | Description | 
|---|---|
 | Create a mutable shallow copy of this map. | 
 | Returns the entries from the map. | 
 | Returns a specified element from the map. | 
 | Returns a boolean indicating whether an element with the specified key exists or not. | 
 | Returns the keys of this map. | 
 | Returns the number of elements in the map. | 
 | Optionally returns a specified element from the map. | 
 | Returns the values of this map. | 
copyMut 
copyMut(): MutMap
Create a mutable shallow copy of this map.
entries 
entries(): MutArray<ArrayEntry>
Returns the entries from the map.
get 
get(key: str): <T>
Returns a specified element from the map.
If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the map.
keyRequired 
- Type: str
 
The key of the element to return.
has 
has(key: str): bool
Returns a boolean indicating whether an element with the specified key exists or not.
keyRequired 
- Type: str
 
The key of the element to test for presence.
keys 
keys(): MutArray<str>
Returns the keys of this map.
size 
size(): num
Returns the number of elements in the map.
TODO: For now this has to be a method rather than a getter as macros only work on methods https://github.com/winglang/wing/issues/1658
tryGet 
tryGet(key: str): <T>?
Optionally returns a specified element from the map.
keyRequired 
- Type: str
 
The key of the element to return.
values 
values(): Array
Returns the values of this map.
MutMap 
Mutable Map.
Methods 
| Name | Description | 
|---|---|
 | Removes all elements. | 
 | Create an immutable shallow copy of this map. | 
 | Removes the specified element from a map. | 
 | Returns the entries from the map. | 
 | Returns a specified element from the map. | 
 | Returns a boolean indicating whether an element with the specified key exists or not. | 
 | Returns the keys of this map. | 
 | Adds or updates an entry in a Map object with a specified key and a value. | 
 | Returns the number of elements in the map. | 
 | Optionally returns a specified element from the map. | 
 | Returns the values of this map. | 
clear 
clear(): void
Removes all elements.
copy 
copy(): Map
Create an immutable shallow copy of this map.
delete 
delete(key: str): bool
Removes the specified element from a map.
keyRequired 
- Type: str
 
The key.
entries 
entries(): MutArray<ArrayEntry>
Returns the entries from the map.
get 
get(key: str): <T>
Returns a specified element from the map.
If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the map.
keyRequired 
- Type: str
 
The key of the element to return.
has 
has(key: str): bool
Returns a boolean indicating whether an element with the specified key exists or not.
keyRequired 
- Type: str
 
The key of the element to test for presence.
keys 
keys(): MutArray<str>
Returns the keys of this map.
set 
set(key: str, value: <T>): void
Adds or updates an entry in a Map object with a specified key and a value.
TODO: revisit this macro after we support indexed args https://github.com/winglang/wing/issues/1659
keyRequired 
- Type: str
 
The key of the element to add.
valueRequired 
- Type: <T>
 
The value of the element to add.
size 
size(): num
Returns the number of elements in the map.
TODO: For now this has to be a method rather than a getter as macros only work on methods https://github.com/winglang/wing/issues/1658
tryGet 
tryGet(key: str): <T>?
Optionally returns a specified element from the map.
keyRequired 
- Type: str
 
The key of the element to return.
values 
values(): Array
Returns the values of this map.
Structs 
ArrayEntry 
Array entry representation.
Initializer 
let ArrayEntry = ArrayEntry{ ... };
Properties 
| Name | Type | Description | 
|---|---|---|
 | str | The entry key. | 
 |  | The entry value. | 
keyRequired 
key: str;
- Type: str
 
The entry key.
valueRequired 
value: <T>;
- Type: <T>
 
The entry value.