-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ternary Operator '?' #403
Comments
Lots of issues in the proposed example, which would make it impossible.
With the above, you have to keep in mind that the quotation mark is shorthand for PRINT. Try a simple Issue 2, is that the colon is a command separator. Which then means that issue 3 is simply the quote left dangling all by itself at the end there. I'd think this type of thing might would be best served via an user function:
Which then could go into your example code as: |
This make sense, and I forgot about the print short-cut, and colon separator. Adding a Ternary Operator doesn't work like any other QB64 syntax, so it would have to be sort-of hard-coded in the lexer/compiler. |
VB and friends have the IIf function. However, both the true-part and the false-part are evaluated in those languages which IMO can cause subtle issues that are hard to catch. If something like Also see #211. |
In a lot languages, the ones I can think of are C++, and C# a '?' question mark can be used to do ternary operators.
C++/C#:
result = (a >= 45) ? "true": "false";
QB64?:
Print (a >= 45) ? "true": "false"
It could make simple if statements easier, and stuff.
The options could be uses of function too like:
clamp(1, a, 10)
or something.Just a more compact, and easier way to do smaller conditional things.
The text was updated successfully, but these errors were encountered: