Quantcast
Channel: Julia ternary operator without `else` - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Julia ternary operator without `else`

$
0
0

Consider the ternary operator in Julia

julia> x = 1 ; y = 2julia> println(x < y ? "less than" : "not less than")less than

Question: Is there a way to omit the : part of the statement ? Something which would be equivalent to

if condition    # dosomethingend

without writing that if the condition is not met, nothing should be done.

NB: I researched the answer but nothing came out, even in related questions (1, 2)


Viewing all articles
Browse latest Browse all 3

Trending Articles