Ternary conditional operator: Difference between revisions

Content deleted Content added
m ?: in style guidelines: Add note that appropriate use reduces the probability of buggy code vs. its less concise counterparts
+haskell
Line 1:
'''<code>?:</code>''' is a [[ternary operator]] that is part of the syntax for a basic [[conditional statement|conditional expression]] in several [[programming language]]s including [[C (programming language)|C]], [[Objective-C]], [[C++]], [[C Sharp (programming language)|C#]], [[D programming language|D]], [[Java (programming language)|Java]], [[JavaScript]], [[Linoleum programming language|Linoleum]], [[Perl]], [[PHP]], [[Tcl]], [[Ruby programming language|Ruby]], and [[Verilog]]. Its origin comes from [[BCPL]], whose equivalent syntax for E1&nbsp;?&nbsp;E2&nbsp;:E3 was E1&nbsp;->&nbsp;E2,&nbsp;E3<ref>{{ cite web | url = http://cm.bell-labs.com/cm/cs/who/dmr/bcpl.pdf | work = BCPL Reference Manual | title = BCPL Ternary operator (page 15) }}</ref>. Languages derived from BCPL tend to feature this operator. Some other languages such as [[Haskell programming language|Haskell]] have an if-else expression (rather than statement) which behaves similarly.
 
==Conditional assignment==