File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1
1
type t <'a > = Js .Dict .t <'a >
2
2
3
3
@get_index external get : (t <'a >, string ) => option <'a > = ""
4
+ @get_index external getUnsafe : (t <'a >, string ) => 'a = ""
4
5
@set_index external set : (t <'a >, string , 'a ) => unit = ""
5
6
@val external delete : 'a => unit = "delete"
6
7
Original file line number Diff line number Diff line change @@ -24,6 +24,24 @@ switch dict->Dict.get("someKey") {
24
24
@get_index
25
25
external get: (t<'a>, string) => option<'a> = ""
26
26
27
+ /**
28
+ Returns the value at the provided key.
29
+
30
+ ## Examples
31
+ ```rescript
32
+ let dict = Dict.fromArray([("someKey", "someValue")])
33
+
34
+ dict->Dict.getUnsafe("someKey") == "someValue"
35
+ dict->Dict.getUnsafe("otherKey") // Undefined behaviour
36
+ ```
37
+
38
+ ## Important
39
+
40
+ - This is an unsafe operation, it assumes `key` exists in the Dict.
41
+ */
42
+ @get_index
43
+ external getUnsafe: (t<'a>, string) => 'a = ""
44
+
27
45
/**
28
46
`set(dictionary, key, value)` sets the value at the provided key to the provided value.
29
47
You can’t perform that action at this time.
0 commit comments