Content deleted Content added
Moggie2002 (talk | contribs) m Added reference to BCPL grammar |
Moggie2002 (talk | contribs) 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 ? E2 :E3 was E1 -> E2, E3<ref>
▲'''<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 ? E2 :E3 was E1 -> E2, 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]]
|