nreco / lambdaparser

Runtime parser for string expressions (formulas, method calls). Builds dynamic LINQ expression tree and compiles it to lambda delegate.
http://www.nrecosite.com/
MIT License
309 stars 55 forks source link

Sequence of ternary operators #43

Closed VitaliyMF closed 1 year ago

VitaliyMF commented 1 year ago

Currently ternary operator requires extra brackets to get 'switch-like' evaluation flow, for example:

a<0 ? 0 : (a>100 ? 100 : -a)

In case when there are many 'elseif' this requires a lot of nested brackets. To avoid that it makes sense to allow next ternary operator for part (which is currently not allowed), this makes possible to use expressions like that:

v<0 ? "red"
: v<25 ? "white" 
: v<50 ? "lightgreen" 
: "green"
VitaliyMF commented 1 year ago

Shipped in 1.1.0