3 ms·
>>java programmer would probably be familiar with it And also C, C++, and Objective-C programmers. I'm sure there are more languages that use that operator tha
by felipemnoa 7y ago
>>java programmer would probably be familiar with it
And also C, C++, and Objective-C programmers. I'm sure there are more languages that use that operator that I have not mentioned here.
- scardine 7y agoI have not touched PHP in the last 10 years but if memory serves it also has the ternary operator. Ok, lets try it: $ php -a Interactive mode enabled php > echo 1 == 1 ? "foo" : "bar"; foo php > echo 1 == 2 ? "foo" : "bar"; bar Looks like javascript has it too: 1 == 1 ? "foo" : "bar" "foo" 1 == 2 ? "foo" : "bar" "bar"
- amenghra 7y agoBe careful, php’s ternary operator precedence is different from (most) other languages’ (consult binding direction). The use of parenthesis is highly encouraged...
- jefftk 7y agoSure, but the article is written with Java programmers in mind and doesn't mention any of the other languages.