Factor handbook > The language > Collections

Next:Directed graph utilities

A box is a container which can either be empty or hold a single value.

Creating an empty box:
<box> ( -- box )

Storing a value and removing a value from a box:
>box ( value box -- )

box> ( box -- value )

Safely removing a value:
?box ( box -- value/f ? )

Testing if a box is full can be done by reading the occupied slot.