I’m trying to convert some code to coffeescript and I’m having problems with this:
var $el = $('<span/>', {
class : 'myclass',
click : function () {
var $this = $(this)
if (foo) { // radio & check
baz($this)
}else{
bla($this)
}
}
});
I wrote in coffee like so:
$el = $('<span/>',
class: 'myclass'
click: ->
$this = $(this)
if foo
baz $this
else
bla $this
)
Which works just fine, but I really dislike that last parenthesis, is there any way I could write this code without parens, just indentation?
Works fine if you drop both parentheses.
See also: http://js2coffee.org/