是什么?:运算符 [英] What is the ?: operator
本文介绍了是什么?:运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Objective-C code的一个例子,我发现这个操作符
In an example of Objective-C code I found this operator
self.itemViews[@(0)] ?: [self.dataSource slidingViewStack:self viewForItemAtIndex:0 reusingView:[self dequeueItemView]];
在code并在苹果LLVM编译4.2
The code does compile under Apple LLVM 4.2.
我遇到的唯一的事情是作为一个向量运算符,但我不认为Objective-C的,并为此事C,具有矢量运营商。所以,有人可以请给该运营商的参考和或文件。
The only thing I came across was in being a vector operator, but I don't think Objective-C, and for that matter C, has vector operators. So can someone please give reference and or documentation of this operator.
推荐答案
:
是C的条件运算符的
a ? b : c
收益率 B
值,如果 A
不同于 0
和 C
如果 A
等于 0
。
yields b
value if a
is different than 0
and c
if a
is equal to 0
.
一个GNU扩展(条件省略操作数)允许,没有第二个操作数使用它:
A GNU extension (Conditional with Omitted Operand) allows to use it with no second operand:
x ? : y
等同于
x ? x : y
这篇关于是什么?:运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文