I’m writing a rock paper scissor game with Coffee Script and the code is not compiling as I’d expect.
CoffeeScript
if choice is opponent_choice then alert "Tie!"
Compiles to
if (choice === opponent_choice) alert("Tie!");
But I was expecting
if (choice === opponent_choice) {
alert("Tie!");
}
What do I need to change for this to compile in the way I expected?
If there’s only one statement on a line, you don’t need the braces. They are functionally identical, and coffeescript compiler optimizing the output to use the least amount of characters.