Top "Ternary-operator" questions

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

How to use the ternary operator inside an interpolated string?

I'm confused as to why this code won't compile: var result = $"{fieldName}{isDescending ? " desc" : string.Empty}"; If I split it …

c# .net ternary-operator string-interpolation c#-6.0
What is ?: in PHP 5.3?

Possible Duplicate: What are the PHP operators “?” and “:” called and what do they do? From http://twitto.org/ <?PHP …

php php-5.3 ternary-operator conditional-operator language-construct
Which coding style you use for ternary operator?

I keep it in single line, if it's short. Lately I've been using this style for longer or nested ternary …

php language-agnostic coding-style ternary-operator
PHP Shorthand ternary operator "?:" Parse error unexpected ":"

I've just uploaded some old PHP files to a new server and am getting parse errors (Unexpected ':') on …

php syntax ternary-operator php-5.2
Alternative to nested ternary operator in JS

I personally love ternary operators, and in my humble opinion, they make complicated expressions very easy to digest. Take this …

javascript ternary-operator eslint
Django Template Ternary Operator

I was wondering if there was a ternary operator (condition ? true-value : false-value) that could be used in a Django template. …

python django templates ternary-operator
Setting parameter to DBNull.Value using ternary syntax gives error?

I have the following bit of code to set a parameter that will be used in an INSERT statement to …

c# .net enterprise-library ternary-operator
getting error: cannot take the address of an rvalue of type 'int'

I tryed to compile old code with new compiler and got the next error: error: cannot take the address of …

c gcc ternary-operator conditional-operator addressof
Ternary operator and string concatenation quirk?

Hi I just want to know why this code yields (at least for me) an incorrect result. Well, probably i'm …

php ternary-operator string-concatenation