Tuesday 23 February 2016

Julia: Ternary operator (?:)

Ternary operator( ?: )
Returns one of two expressions depending on a condition.

Syntax
condition ? expression1 : expression2

Returns expression1 if the condition evaluates to true other wise returns expression 2.
julia> a=10;

julia> info=((a==10)?"a is equal to 10":"a is not equal to 10")
"a is equal to 10"

julia> a=11;

julia> info=((a==10)?"a is equal to 10":"a is not equal to 10")
"a is not equal to 10"



Previous                                                 Next                                                 Home

No comments:

Post a Comment