Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional operator in Coffeescript

I really like this:

var value = maxValue > minValue ? minValue : maxValue; 

Is there something equally concise in Coffescript?

like image 949
Blub Avatar asked Nov 17 '11 16:11

Blub


People also ask

How do you define a function in CoffeeScript?

The syntax of function in CoffeeScript is simpler as compared to JavaScript. In CoffeeScript, we define only function expressions. The function keyword is eliminated in CoffeeScript. To define a function here, we have to use a thin arrow (->).

What can you do with CoffeeScript?

CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Specific additional features include list comprehension and destructuring assignment.


1 Answers

value = if maxValue > minValue then minValue else maxValue 
like image 155
Tim Cooper Avatar answered Nov 10 '22 19:11

Tim Cooper