Skip to main content

API Reference

Classes

Map

Immutable Map.

Methods

NameDescription
copyMut
Create a mutable shallow copy of this map.
entries
Returns the entries from the map.
get
Returns a specified element from the map.
has
Returns a boolean indicating whether an element with the specified key exists or not.
keys
Returns the keys of this map.
size
Returns the number of elements in the map.
tryGet
Optionally returns a specified element from the map.
values
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

NameDescription
clear
Removes all elements.
copy
Create an immutable shallow copy of this map.
delete
Removes the specified element from a map.
entries
Returns the entries from the map.
get
Returns a specified element from the map.
has
Returns a boolean indicating whether an element with the specified key exists or not.
keys
Returns the keys of this map.
set
Adds or updates an entry in a Map object with a specified key and a value.
size
Returns the number of elements in the map.
tryGet
Optionally returns a specified element from the map.
values
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

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

NameTypeDescription
key
strThe entry key.
value
<T>
The entry value.

keyRequired
key: str;
  • Type: str

The entry key.


valueRequired
value: <T>;

The entry value.