Back to Lo

Core Coalesceorempty

docs/data/core-coalesceorempty.md

1.53.0325 B
Original Source

Returns the first non-zero value from the provided comparable arguments, or the zero value if all arguments are zero.

go
result := lo.CoalesceOrEmpty("", "foo", "bar")
// "foo"

result = lo.CoalesceOrEmpty("", "")
// ""

result = lo.CoalesceOrEmpty(0, 42, 100)
// 42

result = lo.CoalesceOrEmpty(0.0, 0.0, 0.0)
// 0.0