Skip to content

Conversation

@rminderhoud
Copy link
Contributor

@rminderhoud rminderhoud commented Mar 17, 2025

Avoids evaluating both the true and false branch of the ternary.

This can help if you are writing an expression where one side of the ternary might result in an invalid array access, e.g. read_mail_index < inbox.size ? inbox[read_mail_index].from : inbox[1234].from

exjam and others added 2 commits March 17, 2025 11:33
Avoids evaluating both the true and false branch of the ternary.

This can help if you are writing an expression where one side of the
ternary might result in an invalid array access, e.g.
read_mail_index < inbox.size ? inbox[read_mail_index].from : ''
Copy link
Owner

@mikke89 mikke89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, it's a very nice improvement! I guess we can say that the data expressions just became a scripting language now that we have branching, heh.

Overall looks very nice, a few minor comments.

It looks correct to me, although I would be a lot more confident if we could add some tests as well. Could you add that?

@rminderhoud
Copy link
Contributor Author

Added a basic test to show that only one side of the ternary gets evaluated

@mikke89
Copy link
Owner

mikke89 commented Mar 20, 2025

Great stuff, looks good to me!

I think the one build failure is unrelated to this PR. I'll see if I can fix it on master and then I'll merge this one.

@mikke89 mikke89 merged commit 010765e into mikke89:master Mar 20, 2025
31 of 32 checks passed
@mikke89
Copy link
Owner

mikke89 commented Mar 20, 2025

Thanks for the PR!

@rminderhoud rminderhoud deleted the ralph/ternary branch September 22, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants