@@ -17,7 +17,7 @@ Use `Dict.getUnsafe` only when you are sure the key exists (i.e. when iterating
1717
1818## Examples
1919```rescript
20- let dict = Dict.fromArray([( "key1", "value1"), ( "key2", "value2")])
20+ let dict = dict{ "key1": "value1", "key2": "value2"}
2121let value = dict->Dict.getUnsafe("key1")
2222Console.log(value) // value1
2323```
@@ -30,7 +30,7 @@ Returns the value at the provided key, if it exists. Returns an option.
3030
3131## Examples
3232```rescript
33- let dict = Dict.fromArray([( "someKey", "someValue")])
33+ let dict = dict{ "someKey": "someValue"}
3434
3535switch dict->Dict.get("someKey") {
3636| None => Console.log("Nope, didn't have the key.")
@@ -59,7 +59,7 @@ external set: (dict<'a>, string, 'a) => unit = ""
5959
6060## Examples
6161```rescript
62- let dict = Dict.fromArray([( "someKey", "someValue")])
62+ let dict = dict{ "someKey": "someValue"}
6363
6464dict->Dict.delete("someKey")
6565```
@@ -189,7 +189,7 @@ external assign: (dict<'a>, dict<'a>) => dict<'a> = "Object.assign"
189189
190190## Examples
191191```rescript
192- let dict = Dict.fromArray([( "key1", "value1"), ( "key2", "value2")])
192+ let dict = dict{ "key1": "value1", "key2": "value2"}
193193let dict2 = dict->Dict.copy
194194
195195// Both log `["key1", "key2"]` here.
@@ -206,7 +206,7 @@ external copy: (@as(json`{}`) _, dict<'a>) => dict<'a> = "Object.assign"
206206
207207## Examples
208208```rescript
209- let dict = Dict.fromArray([( "key1", "value1"), ( "key2", "value2")])
209+ let dict = dict{ "key1": "value1", "key2": "value2"}
210210
211211dict->Dict.forEach(value => {
212212 Console.log(value)
@@ -220,7 +220,7 @@ let forEach: (dict<'a>, 'a => unit) => unit
220220
221221## Examples
222222```rescript
223- let dict = Dict.fromArray([( "key1", "value1"), ( "key2", "value2")])
223+ let dict = dict{ "key1": "value1", "key2": "value2"}
224224
225225dict->Dict.forEachWithKey((value, key) => {
226226 Console.log2(value, key)
@@ -235,10 +235,25 @@ let forEachWithKey: (dict<'a>, ('a, string) => unit) => unit
235235## Examples
236236
237237```rescript
238- let dict = Dict.fromArray([( "key1", 1), ( "key2", 2)])
238+ let dict = dict{ "key1": 1, "key2": 2}
239239
240240dict->Dict.mapValues(v => v + 10)->Dict.toArray // [("key1", 11), ("key2", 12)]
241241dict->Dict.mapValues(v => Int.toString(v))->Dict.toArray // [("key1", "1"), ("key2", "2")]
242242```
243243*/
244244let mapValues : (dict <'a >, 'a => 'b ) => dict <'b >
245+
246+ /**
247+ `has(dictionary, "key")` returns true if the "key" is present in the dictionary.
248+
249+ ## Examples
250+
251+ ```rescript
252+ let dict = dict{"key1": Some(1), "key2": None}
253+
254+ dict->Dict.has("key1") // true
255+ dict->Dict.has("key2") // true
256+ dict->Dict.has("key3") // false
257+ ```
258+ */
259+ let has : (dict <'a >, string ) => bool
0 commit comments