expr icon indicating copy to clipboard operation
expr copied to clipboard

elif doesn't work

Open KyleSanderson opened this issue 9 months ago • 3 comments

Amazing how expr has cloned a lot of external built-ins. We're very close to this doing native filtering with else if conditional branching.

KyleSanderson avatar Apr 07 '25 03:04 KyleSanderson

elif, you mean else if? =))

True, Else if should be added.

antonmedv avatar Apr 07 '25 07:04 antonmedv

What would an implementation of this look like? Any examples I can look at where you have a conditional branch?

KyleSanderson avatar Apr 11 '25 20:04 KyleSanderson

I think the implementation should be something more generics, i.e. support multiple conditions and multiple exprs and reduce if/elif/else into it, or support new syntax entirely like: switch { case con1: case con2: ... default: }

type MultiConditionalNode struct {
	base
	Conds []Node
	Exprs []Node
	DefaultExpr Node
}

h2hoang avatar Jul 23 '25 02:07 h2hoang