Skip to content

Commit 6375876

Browse files
committed
Object.set documentation
1 parent d7601b9 commit 6375876

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Core__Object.res

+14-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,20 @@ x->Object.getSymbol(fruit) // Some("banana")
109109
external getSymbol: ({..}, Core__Symbol.t) => option<'a> = ""
110110
@get_index external getSymbolUnsafe: ({..}, Core__Symbol.t) => 'a = ""
111111

112-
@set_index external set: ({..}, string, 'a) => unit = ""
112+
/**
113+
`set(name, value)` assigns a value to the named object property, overwriting the previous value if any. See [Working with Objects on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#objects_and_properties)
114+
115+
## Examples
116+
117+
```rescript
118+
{"a": 1}->Object.set("a", 2) // {"a": 2}
119+
{"a": 1}->Object.set("a", None) // {"a": None}
120+
{"a": 1}->Object.set("b", 2) // {"a": 1, "b": 2}
121+
```
122+
*/
123+
@set_index
124+
external set: ({..}, string, 'a) => unit = ""
125+
113126
@set_index external setSymbol: ({..}, Core__Symbol.t, 'a) => unit = ""
114127

115128
/**

0 commit comments

Comments
 (0)