Top "Conditional-operator" questions

The conditional operator is a ternary operator that is part of the syntax for a basic conditional expression in several programming languages.

Iif equivalent in C#

Is there an IIf equivalent in C#? Or similar shortcut?

c# .net conditional-operator iif-function
Ternary operator (?:) in Bash

Is there a way to do something like this int a = (b == 5) ? c : d; using Bash?

bash syntax conditional-operator
Is there a conditional ternary operator in VB.NET?

In Perl (and other languages) a conditional ternary operator can be expressed like this: my $foo = $bar == $buz ? $cat : $dog; …

vb.net operators conditional-operator short-circuiting
What is the idiomatic Go equivalent of C's ternary operator?

In C/C++ (and many languages of that family), a common idiom to declare and initialize a variable depending on …

go ternary-operator conditional-operator
twig: IF with multiple conditions

It seem I have problem with a twig if statement. {%if fields | length > 0 || trans_fields | length > 0 -%} The …

php twig conditional-operator
Question mark and colon in JavaScript

I came across the following line hsb.s = max != 0 ? 255 * delta / max : 0; What do the ? and : mean in this context?

javascript syntax operators conditional-operator
What is the Java ?: operator called and what does it do?

I have been working with Java a couple of years, but up until recently I haven't run across this construct: …

java syntax ternary-operator conditional-operator
bash "if [ false ];" returns true instead of false -- why?

Why does the following output True? #!/bin/sh if [ false ]; then echo "True" else echo "False" fi This will always …

bash boolean conditional-operator
Javascript one line If...else...else if statement

I know you can set variables with one line if/else statements by doing var variable = (condition) ? (true block) : (else …

javascript conditional-operator
Benefits of using the conditional ?: (ternary) operator

What are the benefits and drawbacks of the ?: operator as opposed to the standard if-else statement. The obvious ones being: …

c# conditional-operator