question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ternary operator?

See original GitHub issue

One kinda annoying usecase are lambdas with just one if like:

GroupEnum(g, p, Filter(() -> begin
    if GetFilterUnit().getTypeId() == 'z000'
        ...
    else
        ...
end))

which requires the begin/end keywords I would prefer a 1line solution

GroupEnum(g, p, Filter(() -> if GetFilterUnit().getTypeId() == 'z000' then ... else ...))

which should still allow linebreaks inside it for readability. Ideally also working without else case for lambdas. and also this maybe https://github.com/peq/WurstScript/issues/464

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
peqcommented, Aug 15, 2017

Yes, you could do something stupid like this:

int x = 0
int y = 1 < 3 ? begin
    x = 40
    return 2
end : begin
    x = 60
    return 3
end

But you should not 😉

1reaction
IgorSamuroviccommented, Aug 8, 2017

Why, though, is there any problem with ? and :? Or did you plan to use it for something else? The way I see it ? : should be pretty decent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional (ternary) operator - JavaScript - MDN Web Docs
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?)
Read more >
Ternary conditional operator - Wikipedia
In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several ......
Read more >
the ternary conditional operator - Microsoft Learn
The conditional operator ?: , also known as the ternary conditional operator, evaluates a Boolean expression and returns the result of one ...
Read more >
Java Ternary Operator with Examples - GeeksforGeeks
Java ternary operator is the only conditional operator that takes three operands. It's a one-liner replacement for the if-then-else ...
Read more >
Make Your Code Cleaner with JavaScript Ternary Operator
This tutorial shows you how to use the JavaScript ternary operator as the shortcut of the if-else statement to make your code cleaner....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found