Ternary conditional operator: Difference between revisions

Content deleted Content added
Link suggestions feature: 3 links added.
 
Line 90:
=== ALGOL 60 ===
 
ALGOL 60 introduced [[ALGOL 60#Expressions and compound statements|conditional expressions]] (thus ternary conditionals) to [[imperative programming]] languages.
 
'''if''' <boolean expression> '''then''' <expression> '''else''' <expression>
Line 424:
</syntaxhighlight>
 
But even in this case, the if expression would return unit. You don't need to write the else branch, because the compiler will assume the [[unit type]] on else.
 
===FORTH===
Line 521:
 
===Julia===
In [[Julia (programming language)|Julia]], "Note that the spaces around {{code|?}} and {{code|:}} are mandatory: an expression like {{code|a?b:c}} is not a valid ternary expression (but a [[newline]] is acceptable after both the {{code|?}} and the {{code|:}})."<ref>{{Cite web|url=https://docs.julialang.org/en/v1/manual/control-flow/#man-conditional-evaluation-1|title=Control Flow · The Julia Language|website=docs.julialang.org|access-date=2020-03-12}}</ref>
 
===JavaScript===