Skip to content
Node: ternary ? :, nullish ??5 APIs

cond

Package cond provides ternary and nullish-coalescing-style helpers, similar to JavaScript's ? : and ?? operators.

import "github.com/sahilkhaire/gox/cond"
## API reference

Select a symbol below — each page explains what it does, shows Node.js vs Go comparisons, and includes a runnable example.

Functions

SymbolNode.jsKindSummary
Coalescea ?? b ?? cfuncCoalesce returns the first value that is not the zero value (Node: a ?? b ?? c).
CoalesceFnobj?.field ?? "guest"funcCoalesceFn returns the first non-zero result from the given functions, in order.
CoalescePtrptr ?? fallbackfuncCoalescePtr returns the first non-nil pointer's value, or zero if all nil.
Ifcond ? a : bfuncIf returns a when cond is true, otherwise b (Node: cond ? a : b).
IfLazycond ? f() : g()funcIfLazy evaluates a or b lazily via thunks (Node: cond ? a() : b()).

MIT Licensed · Built for Node.js developers moving to Go