Class Box<T>

Source
Expand description

A generic container that holds a value of type T.

import { Box } from '../src/index.js';

function increment(counter: Box<number>) {
counter.value++;
}

const counter = new Box(0);

increment(counter);

console.log(counter.value); // 1

Constructors§

Source§

new Box<T>(value: T): Box<T>

Properties§

Source§

public value: T