ternary operator 三元运算子 ; 三元运算符 ; 三目运算符
Ternary Conditional Operator 三元条件运算符 ; 三目运算符
ternary if-else operator 三元运算符
This new operator is, in fact, a shortcut notation for the ternary operator.
这个新操作符实际上是一个三目操作符的便捷记法。
PHP has the ternary operator (foo?bar:baz) and an enormous (and unwieldy) list of function names, with all kinds of naming conventions; you'll find Python a lot cleaner.
PHP 使用三元操作符(foo? bar:baz)和冗长的函数名列表,而命名约定更是无所不有;相反,您会发现 Python 要简洁多了。
This expression can be as simple as a variable (as shown in Listing 2) or a method call (like getList()), or a complex expression that involves boolean logic or a ternary operator.
表达式可以简单到就是一个变量(如清单 2 所示)或者是一个方法调用(例如 getList()),亦或是包含布尔逻辑或三目运算符的复杂表达式。
应用推荐