Python, Java and Scala have ternary operators. What is the equivalent in Julia?
You've learned about the ternary conditional operator in Ruby, this operator allows you to write compact conditional statements which can make your code easier or harder to read depending on the situation.
The ternary operator is a way of writing conditional statements in Python. As the name ternary suggests, this Python operator consists of three operands. The ternary operator can be thought of as a simplified, one-line version of the if-else statement to test a condition.
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark ( ? ), then an expression to execute if the condition is truthy followed by a colon ( : ), and finally the expression to execute if the condition is falsy.
Hence with a Java 8 class library the result type of the ternary expression is Executable rather than Member . Some (pre-release) versions of the Java 8 compiler seem to have produced an explicit reference to Executable inside generated code when compiling the ternary operator.
Are you refering to this?
a = true
b = 1
c = 2
julia>a ? b : c
1
a = false
julia>a ? b : c
2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With