4 ms·
It's called 'ternary operator' because it's `?` and `:` and takes three operands.
by delinka 7y ago
It's called 'ternary operator' because it's `?` and `:` and takes three operands.
- jefftk 7y agoI don't like calling it the ternary operator because there are other ternary operators, like "x BETWEEN a AND b" in SQL. Sometimes it's called the "conditional operator" but my experience has been that "question mark operator" is what the most people will understand.
- delinka 7y agoIf you're going to reference other languages, `?` is an operator on its own in Swift. Calling `?:` by the name 'question mark operator' is only naming half of the thing.