expr icon indicating copy to clipboard operation
expr copied to clipboard

Nil safety

Open antonmedv opened this issue 2 years ago • 0 comments

Lets add expr.NilSafe().

err: order is potentialy nil
| order.Amount > 500 or product.Category = xyz
|......^

And users can ckange expression to something like this:

order != nil ? order.Amount > 500 : true

Or to:

order?.Amount ?? 999 > 500

Originally posted by @antonmedv in https://github.com/antonmedv/expr/issues/433#issuecomment-1706818463

antonmedv avatar Sep 06 '23 05:09 antonmedv