Syntax Lookup

Enter some language construct you want to know more about.
This is the @set_index decorator.

The @set_index decorator is used to set a dynamic property on an object, or an index of an array.

Example

ReScriptJS Output
type t

@new external create: unit => t = "Object"
@set_index external set: (t, string, int) => unit = ""
@get_index external get: (t, string) => int = ""

let o = create()
o->set("x", 1)
o->set("y", 3)
o->set("z", 5)

let value = o->get("y")

References