coffeescriptの関数呼び出しと引数の扱い
2312 ワード
通常の引数や省略可能引数をもちつつ、名前付き引数も欲しい。もちろん名前付き引数は省略したらデフォルト値を設定してね。さらにRubyのblockのように最後に関数を受け取りたいな。
ok. これで行けます
foo = ([[a,b,[c=3]...,{config="./cofnig.conf"}={}]...,fn]...) ->
[a,b,c,config,fn]
coffee> foo 1,2, ->
[ 1, 2, 3, './config.conf', [Function] ]
coffee> foo 1,2, config:"/etc/config.conf", ->
[ 1, 2, 3, '/etc/config.conf', [Function] ]
分割代入便利ですねえ。
Author And Source
この問題について(coffeescriptの関数呼び出しと引数の扱い), 我々は、より多くの情報をここで見つけました https://qiita.com/takiuchi/items/10e596e248fc46dfc5f8著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .