Skip to content

Instantly share code, notes, and snippets.

@yulanggong
Created December 16, 2012 14:48
Show Gist options
  • Save yulanggong/4308003 to your computer and use it in GitHub Desktop.
Save yulanggong/4308003 to your computer and use it in GitHub Desktop.
三目运算该怎么写?
//第一种
num < 2
? num < 1
? 0
: 1
: num < 3
? 2
: 3
//第二种
num < 2 ?
num < 1 ?
0 :
1 :
num < 3 ?
2 :
3 ;
//第三种
num < 1 ? 0 :
num < 2 ? 1 :
num < 3 ? 2 :
3 ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment