Closed
Description
I really like Ruby's way of making the curlies optional when passing a hash as the last argument to a function:
monkey "blah", { :foo => 2, :bar => 3 } # with curlies
monkey "blah", :foo => 2, :bar => 3 # without curlies
It makes it look like named arguments. Is it possible to do the same in CoffeeScript?
monkey("blah", { foo: 2, bar:3 }) # with curlies
monkey("blah", foo: 2, bar:3) # without curlies
Currently, this compiles to:
monkey("blah", {
foo: 2,
bar: 3
});
// with curlies
monkey("blah", foo = 2, bar = 3);
// without curlies
So the second example is valid Coffee, and compiles into an assignment. My suggestion is to make the second one compile to the same code as the first one.
Seems to me like this would be pretty hard on the parser and potentially introduce some confusion, so I'm not sure this is worth it at all, what do you think?