We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents be0bc83 + 0998a56 commit af37d4fCopy full SHA for af37d4f
misc_docs/syntax/operator_ref_value_assignment.mdx
@@ -0,0 +1,45 @@
1
+---
2
+id: "ref-value-assignment"
3
+keywords: ["ref", "assign"]
4
+name: ":="
5
+summary: "This is the `ref value assignment` operator."
6
+category: "operators"
7
8
+
9
+This operator assigns a new value to a `ref`.
10
11
+<CodeTab labels={["ReScript", "JS Output"]}>
12
13
+```res
14
+let total = ref(0)
15
+total := 1
16
+```
17
18
+```js
19
+var total = {
20
+ contents: 0
21
+};
22
23
+total.contents = 1;
24
25
26
+</CodeTab>
27
28
+A `ref` is a builtin record type with a `mutable contents` field. Therefore the `:=` operator is just a shorthand version for the following code:
29
30
31
32
33
34
+total.contents = 1
35
36
37
38
39
40
41
42
43
44
45
0 commit comments