三元运算符

output = (input < 0) ? 0 : input 

等同于:

if input < 0
  output = 0
else
  output = input
end

等同于:

output = input
output = 0 if input < 0

 

posted @ 2015-05-29 15:42  LUCIEN06  阅读(111)  评论(0)    收藏  举报