Dhruv Saxena Dhruv Saxena - 4 months ago 25
CoffeeScript Question

comma in coffee script / framerjs

When do we use a comma after function declaration in coffee script?
For eg, in the code below why is there a comma after Events.DragStart?

layerA.on Events.DragStart, ->
print layerA.draggable.layerCursorOffset

kba kba
Answer

The comma is not after the function declaration but after the first argument. Coffeescript is just a syntax for Javascript, so you can always compile it to Javascript to see what it does.

E.g. pasting your code snippet into the js2.coffee web service yields this Javascript:

layerA.on(Events.DragStart, function() {
  return print(layerA.draggable.layerCursorOffset);
});