| operator == other/any -> bool | Whether this object is equal to the other. |
|---|---|
| clear -> none | Removes all elements from this instance. |
| size -> int | The number of elements in this instance. |
| is-empty -> bool | Whether this instance is empty. |
| contains key/any -> bool | Whether this instance contains the given key. |
| contains-all collection/Collection -> bool | Whether this instance contains all elements of collection. |
| remove key/any -> none | Removes the given key from this instance. |
| remove key/any [--if-absent] -> none | Removes the given key from this instance. |
| remove-all collection/Collection -> none | Removes all elements of collection from this instance. |
| operator [] key/any -> any | Returns the element stored at location key. |
| operator []= key/any value/any -> any | Stores value in the location for the given key. |
| get key/any -> any | Retrieves the value for key. |
| get key/any [--if-absent] -> any | Retrieves the value for key. |
| get key/any [--if-present] -> any | Retrieves the value for key. |
| get key/any [--if-present] [--if-absent] -> any | Retrieves the value for key. |
| get key/any [--init] -> any | Retrieves the value for key. |
| update key/any [updater] -> any | Updates the value of the given key. |
| update key/any [updater] [--if-absent] -> any | Updates the value of the given key. |
| update key/any [updater] --if-absent/any -> any | Updates the value of the given key. |
| update key/any [--init] [updater] -> any | Updates the value of the given key. |
| update key/any --init/any [updater] -> any | Updates the value of the given key. |
| do [block] -> none | Invokes the given block on each key/value pair of this instance. |
| do --reversed/True [block] -> none | |
| do --keys/True --reversed/bool= [block] -> none | Invokes the given block on each key of this instance. |
| do --values/True --reversed/bool= [block] -> none | Invokes the given block on each value of this instance. |
| keys -> List | Returns the keys of this instance as a list. |
| values -> List | Returns the values of this instance as a list. |
| reduce --values/True [block] -> any | Reduces the values of the map into a single value. |
| reduce --values/True --initial/any [block] -> any | Reduces the values of the map into a single value. |
| reduce --keys/True [block] -> any | Reduces the keys of the map into a single value. |
| reduce --keys/True --initial/any [block] -> any | Reduces the keys of the map into a single value. |
| reduce --initial/any [block] -> any | Reduces the map entries into a single value. |
| any --keys/True [predicate] -> bool | Whether at least one key in the map satisfies the given predicate. |
| any --values/True [predicate] -> bool | Whether at least one value in the map satisfies the given predicate. |
| any [predicate] -> bool | Whether at least one key-value pair in the map satisfies the given predicate. |
| every --keys/True [predicate] -> bool | Whether all keys in the map satisfy the given predicate. |
| every --values/True [predicate] -> bool | Whether all values in the map satisfy the given predicate. |
| every [predicate] -> bool | Whether all key-value pairs in the map satisfy the given predicate. |
| copy -> Map | Copies the map. |
| map [block] -> Map | Invokes the given block on each key/value pair and returns a new map with the results. |
| map --in-place/True [block] -> none | Maps the values of this instance. |
| filter --in-place/bool= [predicate] -> Map | Filters this instance using the given predicate. |
| stringify -> string | |
| first -> any | The first key of the map by insertion order. |
| last -> any | The last key of the map by insertion order. |
map := { "a": 1, "b": 2 }
// Double the values. (Key is not used).
doubled := map.map: | _ value | value * 2
print doubled // => { "a": 2, "b": 4 }
// Prefix the values with the key.
prefixed := map.map: | key value | "$key-$value"
print prefixed // => { "a": "a-1", "b": "b-2" }
class Pin:
number/int
constructor .number:
operator == other:
if other is not Pin: return false
return number == other.number
hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).