在CoffeeScript中的三元操作

15 浏览
0 Comments

在CoffeeScript中的三元操作

我需要根据条件设置a的值。使用CoffeeScript,有什么最简洁的方法吗?

例如,以下是我在JavaScript中的做法:

a = true  ? 5 : 10  # => a = 5
a = false ? 5 : 10  # => a = 10

0