# ref Create a new anonymous ref cell with an initial value. ## Syntax
[ref $val]
## Parameters - `$val` — Initial value held by the ref. ## Examples
[ref 0]            # #<ref 0>
[ref "hi"]         # #<ref "hi">
def counter [ref 0]
## Returns A new anonymous ref cell wrapping `$val` — the value-scoped counterpart of a `[var x]` binding cell. ## Notes - Refs are single-runtime cells and need no lock: the scheduler is cooperative, so a read or write cannot be preempted midway. - Update closures passed to `swap!` must not suspend (`await`/`sleep`/ `yield`); there is no compare-and-retry. ## See Also `deref`, `reset!`, `swap!`, `ref?`