Objective-C运算符(?)和(:) [英] Objective-C operator (?) and (:)
本文介绍了Objective-C运算符(?)和(:)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
?
和:
在这里表示什么?
#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
推荐答案
正如Kjuly所说,它应该大于符号,这只是一个if语句.
As Kjuly mentioned it should be greater than sign, It's just an if statement.
(a > b) ? a : b
如果a
大于b
,则a
将从MAX(a,b)
函数返回,或者如果b
大于,则if语句为false且将返回b
.
If a
is greater than b
then a
will be returned from MAX(a,b)
function or if b
is greater then if statement will be false and b
will be returned.
检查Evan的答案
这篇关于Objective-C运算符(?)和(:)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文