About 50 results
Open links in new tab
  1. How do you use the ? : (conditional) operator in JavaScript?

    Jun 7, 2011 · The conditional (ternary) operator is the only JavaScript operator that takes three operands. This operator is frequently used as a shortcut for the if statement.

  2. How do I use the conditional (ternary) operator? - Stack Overflow

    The ternary operator ? is a way of shortening an if-else clause, and is also called an immediate-if statement in other languages (IIf(condition,true-clause,false-clause) in VB, for example).

  3. To ternary or not to ternary? [closed] - Stack Overflow

    The ternary operator can be used in places where the if..else construct can't, for example in return statements, and as function arguments. The same could be achieved without ternary use, but results …

  4. How to write a PHP ternary operator with the elseif portion?

    Closed 5 years ago. How do I write a PHP ternary operator with the elseif portion? I see basic examples with the if and else portions of the PHP ternary operator like this:

  5. syntax - Ternary operator (?:) in Bash - Stack Overflow

    @dutCh's answer shows that bash does have something similar to the "ternary operator" however in bash this is called the "conditional operator" expr?expr:expr (see man bash goto section "Arithmetic …

  6. PHP short-ternary ("Elvis") operator vs null coalescing operator

    Whereas, the ternary operator is a shorthand for if-else. Null Coalescing operator is not meant to replace ternary operator, but in some use cases like in the above example, it allows you to write clean code …

  7. Kotlin Ternary Conditional Operator - Stack Overflow

    May 26, 2017 · Remember Ternary operator and Elvis operator hold separate meanings in Kotlin unlike in many popular languages. Doing expression? value1: value2 would give you bad words by the …

  8. JavaScript ternary operator example with functions

    The ternary operator is common when you're assigning a value to a variable based on a simple condition or you are making multiple decisions with very brief outcomes. The example you cite actually doesn't …

  9. The ternary (conditional) operator in C - Stack Overflow

    The ternary operator is a syntactic and readability convenience, not a performance shortcut. People are split on the merits of it for conditionals of varying complexity, but for short conditions, it can be useful …

  10. What is the idiomatic Go equivalent of C's ternary operator?

    Nov 14, 2013 · The C conditional expression (commonly known as the ternary operator) has three operands: expr1 ? expr2 : expr3. If expr1 evaluates to true, expr2 is evaluated and is the result of the …