Quantcast
Channel: Julia ternary operator without `else` - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Nathan Boyer for Julia ternary operator without `else`

&& is commonly used for this because it is short, but you have to know the trick to read it. I sometimes find it more readable to just use a regular old if statement. In Julia, it need not be...

View Article


Answer by Przemyslaw Szufel for Julia ternary operator without `else`

Just do:condition && do_somethingFor an example:2 < 3 && println("hello!")Explanation:&& is a short-circut operator in Julia. Hence, the second value will be only evaluated...

View Article


Julia ternary operator without `else`

Consider the ternary operator in Juliajulia> x = 1 ; y = 2julia> println(x < y ? "less than" : "not less than")less thanQuestion: Is there a way to omit the : part of the statement ? Something...

View Article
Browsing latest articles
Browse All 3 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>