Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Julia have a ternary conditional operator?

Python, Java and Scala have ternary operators. What is the equivalent in Julia?

like image 833
Janek Bogucki Avatar asked Sep 30 '16 11:09

Janek Bogucki


People also ask

Does Ruby have ternary operator?

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.

Are there ternary operator in Python?

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.

Is ternary conditional operator?

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.

Does Java 8 have ternary operator?

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.


1 Answers

Are you refering to this?

a = true
b = 1
c = 2

julia>a ? b : c
1

a = false 

julia>a ? b : c
2
like image 109
isebarn Avatar answered Oct 14 '22 18:10

isebarn