We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a065f50 commit 6372160Copy full SHA for 6372160
lib/core/collections.toit
@@ -3200,6 +3200,19 @@ class Map extends HashedInsertionOrderedCollection_:
3200
3201
The $block is invoked with two arguments for each entry in this instance:
3202
the key and the value. The returned value becomes the new value for the key.
3203
+
3204
+ # Examples
3205
+ ```
3206
+ map := { "a": 1, "b": 2 }
3207
3208
+ // Double the values. (Key is not used).
3209
+ doubled := map.map: | _ value | value * 2
3210
+ print doubled // => { "a": 2, "b": 4 }
3211
3212
+ // Prefix the values with the key.
3213
+ prefixed := map.map: | key value | "$key-$value"
3214
+ print prefixed // => { "a": "a-1", "b": "b-2" }
3215
3216
*/
3217
map [block] -> Map:
3218
result := Map
0 commit comments