coalesce
A nil coalescing operator ?? for Nim
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install coalesce
choosenim install coalesce
git clone https://github.com/piedar/coalesce
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| coalesce | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/piedar/coalesce |
|---|---|
| Homepage | https://github.com/piedar/coalesce |
| Registry Source | nimble_official |
README
coalesce
The coalesce package implements a null coalescing operator ?? for Nim.
examples
The most obvious case is choosing the first non-nil value.
let a: string = nil
let x = a ?? "b"
assert x == "b"
The operator also supports Option[T].
let a: Option[string] = none(string)
let x = a ?? "b"
assert x == "b"
Longer chains work too, and the expression short-circuits if possible.
let result = tryComputeFast(input) ?? tryComputeSlow(input) ?? myDefault
todo
- support for
not nil