Skip to content

With and without

tim-hardcastle edited this page Nov 22, 2025 · 3 revisions

with

We've already seen the use of the with operator to construct new struct values, e.g. Person with name::"Joseph", age::22, where Person is the name of a type and name::"Joseph", age::22 is a tuple of pairs.

We use the same with operator and the same syntax to copy and modify existing values.

This is important because in Pipefish, all values are immutable. You cannot change the nth item of a list or struct, or add a key to a map, or change the value associated with an existing key. Instead, you can ask Pipefish for a copy of the list/map/struct with an element or elements changed. Let's demonstrate this in the TUI, first running a little script to declare some data for us to copy-and-modify.

image

without

The without operator for maps returns a copy of the map with the given key or keys removed.

image

No error is returned if the key is not in the map: Pipefish consistently treats deletion as an idempotent operation.

🧿 Pipefish

Clone this wiki locally