Content deleted Content added
clarity |
mNo edit summary |
||
Line 4:
{{mergefrom|conditional operator|discuss=Talk:Conditional operator#Related Article|date=February 2025}}
In [[computer programming]], the '''ternary conditional operator''' is a [[ternary operator]] that is part of the syntax for basic [[conditional (programming)|conditional expressions]] in several [[programming language]]s. It is commonly referred to as the '''conditional operator''', '''conditional expression''', '''ternary if''', or '''inline if''' (abbreviated '''iif'''). An expression {{code|if a then b else c}} or {{code|a ? b : c}} evaluates to {{code|b}} if the value of {{code|a}} is true, and otherwise to {{code|c}}. One can read it aloud as "if a then b otherwise c". The form {{code|a ? b : c}} is the most common, but alternative
It originally comes from [[CPL (programming language)|CPL]], in which equivalent syntax for <code>''e''<sub>1</sub> ? ''e''<sub>2</sub> : ''e''<sub>3</sub></code> was <code>''e''<sub>1</sub> → ''e''<sub>2</sub>, ''e''<sub>3</sub></code>.<ref>{{cite journal|first=Christopher|last=Strachey|author-link=Christopher Strachey|title=[[Fundamental Concepts in Programming Languages]]|journal=[[Higher-Order and Symbolic Computation]]|volume=13|pages=11–49|year=2000|doi=10.1023/A:1010000313106|s2cid=14124601}}</ref><ref>{{cite book | url = http://www.eah-jena.de/~kleine/history/languages/Richards-BCPL-ReferenceManual.pdf | title = The BCPL Reference Manual | year = 1967 | chapter = 5.5 Conditional expressions | pages = 16–17 | access-date = 2017-03-15 | archive-date = 2016-03-16 | archive-url = https://web.archive.org/web/20160316100234/http://www.eah-jena.de/~kleine/history/languages/Richards-BCPL-ReferenceManual.pdf | url-status = dead }}</ref>
|