sprig icon indicating copy to clipboard operation
sprig copied to clipboard

feature: Add functions safeDefault, safeCoalesce, and nonNil

Open govindbalaji-s opened this issue 1 year ago • 0 comments

Fixes #250

This adds functions similar to default and coalesce but only falls through for nil values, and does not fall through 0, false or "".

Suggestions for better names are welcome. Have picked same names as in #250 .

~IMO safeEmpty should just be ne nil and is not needed.~ ne actually fails when comparing nil and something else. Added a function nonNil for this.

govindbalaji-s avatar Oct 21 '23 20:10 govindbalaji-s