Ternary conditional operator: Difference between revisions

Content deleted Content added
m Added reference to BCPL grammar
m Fix reference, remove unreferenced tag.
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 (see| title = BCPL Ternary operator (page 15)] }}</ref>. Languages derived from BCPL tend to feature this operator.
{{Unreferenced|date=November 2007}}
'''<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>[http://cm.bell-labs.com/cm/cs/who/dmr/bcpl.pdf BCPL Reference Manual (see page 15)]</ref>. Languages derived from BCPL tend to feature this operator.
 
==Conditional assignment==
Line 100 ⟶ 99:
? ''logical comparison'' -> ''code label'';
Although the usage and format are different, it is still a ternary operator (used as a conditional expression) because the three arguments come from the code label and from the two arguments in the logical comparison. (The <code>-></code> operator, which signifies an unconditional [[Branch (computer science)|jump]], takes the place of the <code>:</code> operator.) <!-- this doesn't really make sense -->
 
== References ==
 
{{reflist|2}}
 
[[Category:Conditional constructs]]