cond
Package cond provides ternary and nullish-coalescing-style helpers, similar to JavaScript's ? : and ?? operators.
import "github.com/sahilkhaire/gox/cond"
Select a symbol below — each page explains what it does, shows Node.js vs Go comparisons, and includes a runnable example.
Functions
| Symbol | Node.js | Kind | Summary |
|---|---|---|---|
| Coalesce | a ?? b ?? c | func | Coalesce returns the first value that is not the zero value (Node: a ?? b ?? c). |
| CoalesceFn | obj?.field ?? "guest" | func | CoalesceFn returns the first non-zero result from the given functions, in order. |
| CoalescePtr | ptr ?? fallback | func | CoalescePtr returns the first non-nil pointer's value, or zero if all nil. |
| If | cond ? a : b | func | If returns a when cond is true, otherwise b (Node: cond ? a : b). |
| IfLazy | cond ? f() : g() | func | IfLazy evaluates a or b lazily via thunks (Node: cond ? a() : b()). |