What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

Well-intentioned people tend to ask the same question over and over again: What does this mean:

var foo = bar ? 1 : 0;

It's the thing which most people (notably: most people on SO) call "the ternary operator," but strictly speaking is a conditional operator, but since the person asking generally doesn't know the name and it's not search-engine-friendly, they don't figure out how to find the existing questions, of which there are lots.

So my question is, how could we fix this? Is there a way to help people find results for syntax when they don't know the name?


  • A grammar-and-language-aware question parser?
  • A language syntax reference which correlates to the correct SO tags?
  • Something else?

Nitpicker's corner: Added digression about common usage being incorrect. I think it's missing the point, but perhaps if I spell this out we can talk about the question I'm asking instead.

share|improve this question
What does this do!? var x=x ?? y ?? z ?? 0!? –  Earlz May 6 '10 at 18:00
Technically, it's the conditional operator. It is a ternary operator (and the only one in most languages), but you wouldn't call + the binary operator, would you? –  Super Long Names are Hilarious May 6 '10 at 18:01
Should we have the classic argument about how it's not actually called "The Ternary Operator" :) en.wikipedia.org/wiki/%3F: –  user27414 May 6 '10 at 18:01
If they would only call it the conditional operator, everything would be fine :-) –  nb69307 May 6 '10 at 18:01
Oh, I guess @Stupid beat me to it :P –  user27414 May 6 '10 at 18:01
The syntax reference is not a bad idea (and we could do a glossary too), but it would require the introduction of a new type of SO interaction: the question/answer format isn't that great for such uses (witness the on-site faq). –  dmckee May 6 '10 at 18:02
I answered one of these myself a year ago: stackoverflow.com/questions/798545/…. And from that question, I found two more of the same. This has been a problem for a long time. –  mmyers May 6 '10 at 18:16
@Jon B - I'm not @Stupid, thank you very much. :P –  Super Long Names are Hilarious May 6 '10 at 18:26
@mmyers I love how the PHP and Java questions you linked have exactly the same title barring the actual language choice (and a space before the colon) –  Grace Note May 6 '10 at 18:38
when you edit questions titles like that you break the related questions algorithm just a little more... @lance –  jmfsg May 6 '10 at 18:39
@Down, it seemed like the perfect edit, resistance was futile –  Lance Roberts May 6 '10 at 19:01
This also comes up with bitshift operators, by the way. Not surprisingly, people have trouble searching for << and >>. –  Aarobot May 14 '10 at 14:03
It could be worse: someone could be asking what =()= does. –  Andrew Grimm Oct 22 '10 at 8:23

8 Answers 8

up vote 9 down vote accepted

Maybe it would make sense if the FAQ pointed to a list of the most Frequently Asked Questions on the site, in addition to questions about the site.

share|improve this answer
Well, there was that proposal for a per-tag FAQ a while ago. Not sure if it would help this specific case, though. –  mmyers May 6 '10 at 18:47
meta.stackexchange.com/questions/1195/create-a-tag-homepage-faq (someone needs to flesh that out... But for now, a link back to this should help) –  Shogging through the snow May 6 '10 at 19:04
Well, they are after all frequently asked questions... –  MPelletier Nov 19 '10 at 1:46
-1 - Too obvious. –  Peter Ajtai Nov 19 '10 at 1:51

Your point is valid, but I think this occurs infrequently enough that the existing vote-to-close mechanism is sufficient. Developing a more complex search would probably not be worth the effort.

share|improve this answer
Well, yes and no. Someday (when all the little problems are sorted out...) the team might start thing about making the search "better", and when they do this should go into the pot for consideration. –  dmckee May 6 '10 at 18:00

Why not have an option in the SO search to disable "assumptions" this when checked would allow you to search for what is ? operator and the ? character be weighted in the result.

share|improve this answer
I think that would be a great feature, though I think people might not use it since they would presume it does not exist. Having the automatic search on the title (when you post a question) use such a feature would be good. However, the most popular title for "?" questions is "What does this do"! –  Craig Stuntz May 6 '10 at 18:10
Yea, I'd say if we could have some sorta autodetection then that'd be great –  Earlz May 6 '10 at 23:48

It's the ternary operator

Points for irony. You were joking there yes? Please?

Or as it should be:

It's the ternary conditional operator (which happens to be the only common ternary operator)

share|improve this answer
If there was a unicorn... And only one unicorn... and that unicorn happened to be a plumber named Bob... Then he would probably still be referred to as "The Unicorn" rather than "Bob the plumber". –  Shogging through the snow May 6 '10 at 18:56
@Shog9 - the "only" is the problem. There is no guarantee that there will never be another ternary operator. I'm half tempted to invent a language with gluts of them, just to put this matter to rest. –  Marc Gravell May 6 '10 at 19:10
No irony. And yes, I know what it's called. Even people who didn't would have learned it from reading the questions which caused me to ask this in the first place. But this question is about searching for duplicate answers, and there are twice as many pages in SO with ternary operator as conditional operator . Let's not miss the point here: "How do we steer folks asking questions about ? to the existing answers on the topic?" –  Craig Stuntz May 6 '10 at 19:10
@Carig - Eric Lippert puts it better than I can, on blogs.msdn.com/ericlippert/archive/2010/02/18/… - The trouble with "the ternary operator" is that it describes what it looks like, not what it does. This is why . + => are called the "member access operator", "addition operator" and "lambda operator" and not the "dot operator", "plus operator" and "fat arrow operator". –  Marc Gravell May 6 '10 at 19:12
I'm not attempting to say that common usage is correct. I just want to avoid duplicates and get the folks asking these questions their answers faster. –  Craig Stuntz May 6 '10 at 19:18
@Marc: You should totally do that. And call it, "C?:"... –  Shogging through the snow May 6 '10 at 19:23
@Marc Gravell: actually, I've found that for the purpose of communication, it is often better to call + . => as plus, dot, and fat arrow respectively. In the programming class I'm in, when I said "x assigned with a added by b", people hesitate a bit before understanding what I meant, that doesn't happen if I said "x equals a plus b". Most people have better association with the symbols than the operations themselves. It seems many people mentally translate the name of the operation into symbols in their head, so it's clearer to use symbol's name to skip the translation. –  Lie Ryan Oct 15 '10 at 4:05

A Modest Proposal—a new ternary operator

I'd like to propose a new ternary operator to join the poor lonely conditional operator: the FMA operator. (Officially, it stands for fused multiply-add. Unofficially, it's like FML but with the obvious substitution. :-P)


expr * expr + expr

The point of this operator is, of course, that FMA will be seeing direct processor support soon. A useful secondary effect of this operator is that people have to be clearer about which ternary operator they're referring to. :-)

share|improve this answer
That seems like it should be used as an optimization, not as a distinct language construct. –  Jeremy Banks Nov 19 '10 at 4:59
There are lots of other ternary operators... –  Charles Stewart Nov 19 '10 at 9:27

There's a "faq" tab for each tag that sorts questions by how frequently they're asked, based on links between questions and the like.

share|improve this answer

I'm more for the creation of tags for special characters, like [tag:?] (aaah... you can't do it... The tag formatter is intelligent enough to ignore the special characters. Let's say ). You could have 10/20 of these "special" tags, one for each common "symbol" (for example there are many question about the @ c# verbatim literal). The search engine could then try to match special characters to these tags quite quickly (perhaps simply looking if in a query there is an "isolated" symbol. So if you search for Can you help me? The ? wouldn't be matched. But if you searched for What does ? means it would) Persons that "know" with enough rep could then retag some good Q/A on the site with these tags and the tags of the correct language.

share|improve this answer

While Google can't handle symbols, SymbolHound can:

http://symbolhound.com/?q=%3F+c gives Statement with ? in C as its third hit.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .