Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two object arguments in coffeescript

Tags:

coffeescript

I want to convert

console.log({
  a: 'a'
}, {
  b: 'b'
});

into CoffeeScript. The only way I found is

console.log
  a: 'a',
    b: 'b'

It seems bizarre that a: 'a' and b: 'b' are not indented the same when they are essentially symetric in this situation.

like image 799
Randomblue Avatar asked Feb 12 '12 16:02

Randomblue


1 Answers

Put the comma one in a separated line, one indentation level less than the hash/object, so it's treated as part of the function invocation.

console.log
   a: 'a'
, # indentation level matters!
   b: 'b'

this will not work because the indentation level is the same as hash, so it's treated as part of the hash.

console.log
   a: 'a'
   ,
   b: 'b'
like image 121
Xiaotian Guo Avatar answered Oct 07 '22 15:10

Xiaotian Guo