Skip to content
Johannes Zottele edited this page Sep 19, 2022 · 2 revisions

Dicts are a generic datastructure and with that an exception as Moose doesn't allow you to define custom generic Classes.


Dict[K, V].length() > Int

Returns the number of key-value pairs.

Dict[K, V].flat() > List[(K, V)]

Converts the dictionary to a list where each item is a tuple with the key and value from the dictionary.

Dict[K, V].getItem(K) > V

Gets the item with the provided key.

If the key doesn't exist, it will return nil.

There is syntactic sugar for this function:

dict = {"flo": true, "lisa": false}
println(dict["lisa"])

Dict[K, V].setItem(K, V) > Void

Updates the provided key with the provided value.

There is syntactic sugar for this function:

dict = {"flo": true, "lisa": false}
dict["luis"] = false

Clone this wiki locally