class Money {
public function __construct(
public readonly int $amount,
public readonly string $currency
) {}
public function add(Money $other): self {
return new self($this->amount + $other->amount, $this->currency);
}
}const, Object.freeze(), spread operator {...obj, key: newVal}. Libraries: Immer, Immutable.js.