LoginSignup
17
15

More than 5 years have passed since last update.

CoffeeScriptで即時関数

Posted at

CoffeeScriptで、jsの

instant.js
var foo = (function () {
    // ...
})();

をやりたい場合、

instant.coffee
foo = do ->
    # ...

とすればいい。意外とリファレンスサイトには載ってない。
ちなみに引数を渡したければ以下のように書く。

instant.coffee
foo = do (x) ->
    # ...
17
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
15