coffeescriptの関数呼び出しと引数の扱い


通常の引数や省略可能引数をもちつつ、名前付き引数も欲しい。もちろん名前付き引数は省略したらデフォルト値を設定してね。さらに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] ]

分割代入便利ですねえ。