conditional-operator Questions

1

So someone on a forum asked why this C function (which I added const and restrict to, just in case): void foo(int *const restrict dest, const int *const restrict source) { *dest = (*source != -1) ...

2

Solved

Simplified program as follows struct S { S() {} S(const S &) {} S(S &&) = delete; }; S x; S y = false ? S() : x; is accepted just fine by GCC and Clang, but the latest Visual Studi...

9

Solved

I need a bit of syntax help with a ternary operator which will help me to put the correct marker icons on to my good map. I have three areas 0, 1 and 2 which have unique icons 0, 1 and 2. I used t...
Fiesole asked 13/10, 2011 at 16:49

3

I have get network image and used ternary operator where I can show network image but unable to show default asset image where network image is invalid default image in grid also as this- I am new ...

1

Consider the following useless code snippet, which gives inconsistent results with different compilers (demo) #include <type_traits> char* dummy; const char* const& a = dummy; char* &am...
Dilatometer asked 15/9, 2023 at 6:14

4

Solved

I use C# ? operator when I have if-statements that affects one row and it's all good. But lets say I have this code (using classic if-statements): if(someStatement) { someBool = true; //someBools...
Setscrew asked 24/7, 2014 at 13:18

4

Solved

Is there a difference in performance between the if-else statement and the ternary operator in Python?
Bow asked 17/6, 2017 at 1:10

10

Solved

I know you can set variables with one line if/else statements by doing var variable = (condition) ? (true block) : (else block), but I was wondering if there was a way to put an else if statement i...
Lubeck asked 13/3, 2015 at 22:39

13

is there a way of typing for if like: var = (cond) ? true : false; or do we have to use this format? if (cond) true else false end
Mackenie asked 8/4, 2011 at 12:18

2

Solved

Why do both of the results print the same? final list1 = [ "a", "b", "c" ]; final result1 = true ? list1 : list1..removeWhere((e) => e == "a"); print(resu...
Stickleback asked 15/1, 2024 at 10:17

18

Solved

I have been working with Java a couple of years, but up until recently I haven't run across this construct: int count = isHere ? getHereCount(index) : getAwayCount(index); This is probably a ver...
Villanelle asked 28/4, 2009 at 15:28

11

Solved

So I'm using a shorthand JavaScript if/else statement (I read somewhere they're called Ternary statements?) this.dragHandle.hasClass('handle-low') ? direction = "left" : direction = &quot...
Sculpin asked 19/7, 2012 at 5:32

11

Solved

I've always wondered how to write the "A ? B : C" syntax in a C++ compatible language. I think it works something like: (Pseudo code) If A > B C = A Else C = B Will any veteran C++ program...
Arbitrament asked 25/12, 2008 at 16:27

10

Solved

I've got quite big trouble, because i need to anathematise from styling some input types. I had something like: .registration_form_right input:not([type="radio") { //Nah. } But i don't want to ...
Cheyney asked 9/5, 2010 at 8:42

0

Let's suppose we have some non-copyable and non-movable type Foo, and a function int f(const Foo& foo) { ... // somehow compute the result depending on the value of foo. } Now let's suppose w...
Elise asked 11/10, 2023 at 23:12

14

From what I know, PowerShell doesn't seem to have a built-in expression for the so-called ternary operator. For example, in the C language, which supports the ternary operator, I could write somet...
Danby asked 10/7, 2015 at 13:26

17

Solved

How can I use an inline if statement in JavaScript? Is there an inline else statement too? Something like this: var a = 2; var b = 3; if(a < b) { // do something }

12

Solved

int number = 5; when the number is equal to 5, write true when the number is not equal to 5, write false How do I write a statement for this in ASP.NET using C#?
Tilth asked 5/11, 2009 at 4:15

4

I want to use the if else statement in the ternary operator if (open) { setOpen(false) } else { setOpen(true) navigator.clipboard.writeText(link) } There is no problem in "if" I ca...

12

Solved

I know that in PHP 5.3 instead of using this redundant ternary operator syntax: startingNum = startingNum ? startingNum : 1 ...we can use a shorthand syntax for our ternary operators where applica...
Hoatzin asked 16/1, 2012 at 17:45

8

Apologies if this has been asked before, but I couldn't see it anywhere. Essentially I've come across a scenario where i need to make use of an if statement inside a lambda function. What ma...

32

Solved

Is there a ternary conditional operator in Python?
Siam asked 27/12, 2008 at 8:32

6

Solved

I'm confused about direct assignment and ternary conditional operators precedence: #include<stdio.h> int main(void) { int j, k; j = k = 0; (1 ? j : k) = 1; // first printf("%d %d\n", j,...
Bradawl asked 21/9, 2011 at 12:2

2

Solved

I was working on some C++ code using std::move on shared_ptr and got really weird output. I've simplified my code as below int func(std::shared_ptr<int>&& a) { return 0; } int main(...

11

Solved

In VBA I can do the following: A = B + IIF(C>0, C, 0) so that if C>0 I get A=B+C and C<=0 I get A=B Is there an operator or function that will let me do these conditionals inline in MATLA...
Certain asked 30/1, 2013 at 19:36

© 2022 - 2025 — McMap. All rights reserved.