how should I chain function call in coffeescript

前端 未结 2 1426
醉梦人生
醉梦人生 2021-02-13 01:35

This coffeecode

obj
  .func1()
  .func2()

will result in

obj.func1().func2();

this work find.

But w

相关标签:
2条回答
  • 2021-02-13 01:55

    No way for now. There are ongoing discussions for enabling it:

    • https://github.com/jashkenas/coffee-script/issues/1407
    • https://github.com/jashkenas/coffee-script/issues/1495
    0 讨论(0)
  • 2021-02-13 02:10

    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
    
    0 讨论(0)
提交回复
热议问题