Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 680 Bytes

operator_ref_value_assignment.mdx

File metadata and controls

45 lines (33 loc) · 680 Bytes
idkeywordsnamesummarycategory
ref-value-assignment
ref
assign
:=
This is the `ref value assignment` operator.
operators

This operator assigns a new value to a ref.

<CodeTab labels={["ReScript", "JS Output"]}>

lettotal=ref(0) total:=1
vartotal={contents: 0};total.contents=1;

A ref is a builtin record type with a mutable contents field. Therefore the := operator is just a shorthand version for the following code:

<CodeTab labels={["ReScript", "JS Output"]}>

lettotal=ref(0) total.contents=1
vartotal={contents: 0};total.contents=1;
close