假如你写了这样的代码

if(x>0){

    x+=1;

}else{

    x=0;

}时,其实你可以这样写

x>0?x+=1:0;

五行代码瞬间变一行。

转载于:https://my.oschina.net/love404/blog/407977