docs: add core library overview, map class docs, and link value types to core classes

This commit is contained in:
Bob Nystrom
2015-01-25 19:08:13 +00:00
parent f093d0a42a
commit 1d195f13ea
7 changed files with 156 additions and 14 deletions
+53
View File
@@ -0,0 +1,53 @@
^title Map Class
^category core
An associative collection that maps keys to values. More details [here](../maps.html).
### **clear**
Removes all entries
### **count**
The number of entries in the map.
### **keys**
A [Sequence](sequence.html) that can be used to iterate over the keys in the
map. Note that iteration order is undefined. All keys will be iterated over,
but may be in any order, and may even change between invocations of Wren.
### **iterate**(iterator), **iteratorValue**(iterator)
Implements the [iterator protocol](../control-flow.html#the-iterator-protocol)
for iterating over the elements in the list.
### **removeAt**(key)
### **values**
A [Sequence](sequence.html) that can be used to iterate over the values in the
map. Note that iteration order is undefined. All values will be iterated over,
but may be in any order, and may even change between invocations of Wren.
If multiple keys are associated with the same value, the value will appear
multiple times in the sequence.
### **[**key**]** operator
Gets the value associated with `key` in the map. If `key` is not present in the
map, returns `null`.
:::dart
var map = {"george": "harrison", "ringo": "starr"}
IO.print(map["ringo"]) // "starr".
IO.print(map["pete"]) // "null".
### **[**key**]=**(value) operator
Associates `value` with `key` in the map. If `key` was already in the map, this
replaces the previous association.
It is a runtime error if the key is not a [Bool](bool.html),
[Class](class.html), [Null](null.html), [Num](num.html), [Range](range.html),
or [String](string.html).