Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how should I chain function call in coffeescript

Tags:

coffeescript

This coffeecode

obj
  .func1()
  .func2()

will result in

obj.func1().func2();

this work find.

But when I type this

obj
  .func1 "aaa"
  .func2 "bbb"

it will result in

obj.func1("aaa".func2("bbb"));

I must type like this

obj
  .func1('aaa')
  .func2('bbb')

that result in javsscript

obj.func1('aaa').func2('bbb');

Is there a way to omit parentthese when chain function in coffeescript?

like image 769
Leon Avatar asked Apr 18 '12 06:04

Leon


1 Answers

This issue has just been fixed here.

So, for e.g.:

obj
 .func1 "aaa"
 .func2 "bbb"

will be compiled to

obj.func1("aaa").func2("bbb");

You may need to use the latest version at master branch for now, in npm:

npm install -g http://github.com/jashkenas/coffee-script/tarball/master
like image 148
boh Avatar answered Nov 01 '22 13:11

boh