|Problems? Is your data what you think it is?|
Ternary operator (there's no Trinary operator )by davido (Archbishop)
|on Jul 19, 2006 at 07:04 UTC||Need Help??|
So... which is it?
As of July 2006, Google shows over 420k possible hits for the search term ternary operator. The first 20 hits include Wikipedia: ternary operator, and links to the official documentation for several languages (PHP, Java, and Python). Perl's own perlop also refers to the ?: operator as a "ternary operator". Wikipedia tells us that the term 'ternary operator' comes from the mathematical term 'ternary operation'. It's sometimes (according to wikipedia) called a tertiary operator, as it takes three arguments.
If you google for the search term trinary operator, you get (as of today) almost 28k hits, along with the familiar Google helper, "Did you mean: ternary operator." There are no Wikipedia hits for it, though there is a wikipedia hit for 'trinary' (the word, not an operator).
Given that there are nearly 28 thousand references to "trinary operator", versus 420k hits for 'ternary operator' turned up by Google, it's obvious that there is a significant propensity for name confusion. Here at the monastery we occasionally see posts about the ternary operator, where the node's author mistakenly calls it the trinary operator. Occasionally such nodes get retitled as a hazard to navigation and search-ability.
The purpose of this meditation is to clarify which term is correct in the context of Perl's ?: operator, as well as to provide a quick-reference node title that will be found anytime someone searches for either ternary or trinary here at the Monastery. This should serve as a pre-emptive aid to navigation, reducing the temptation to retitle 'trinary' nodes. I post this as a Meditation, despite its strong "PerlMonks Discussion" flavor because I believe the discussion has merit beyond the scope of only pertaining to the Monastery's goings-on.
So, what's the verdict? Perl's POD, Google's number of hits returned, Wikipedia's blurbs, and the documentation for other popular languages all seem to agree that with regards to the ?: operator, it's called a ternary operator
From a research perspective, those searching for information on the Ternary operator, here at the Monastery, as well as on Google, would probably find additional beneficial posts by searching for the "misspelled" term, Trinary. But the existence of nodes with both 'spellings', and the associated ambiguity shouldn't detract from the fact that Perl has a ternary operator, not a trinary operator.
...or maybe I'm just confused, this is a meditation, after all. ;)