Skip to content

Instantly share code, notes, and snippets.

@func09
Created June 29, 2011 09:52
Show Gist options
  • Save func09/1053552 to your computer and use it in GitHub Desktop.
Save func09/1053552 to your computer and use it in GitHub Desktop.
CoffeeScriptで2つのメソッド引数を取るとき、美しく書きたい・・・
hoge = (func1, func2) ->
alert func1.apply()
alert func2.apply()
# NG
hoge () -> 'a', () -> 'b'
# NG
hoge (() -> 'a', () -> 'b')
# OK 美しくない
hoge () -> 'a'
,
() -> 'b'
# OK 一度変数につっこむ
_1 = () -> 'a'
_2 = () -> 'b'
hoge _1, _2
# OK by @ruedap http://twitter.com/ruedap/status/86018496928022528
hoge (() -> 'a') , (() -> 'b')
@func09
Copy link
Author

func09 commented Jun 29, 2011

一時変数につっこむのが無難かなぁ?

@satyr
Copy link

satyr commented Jun 29, 2011

hoge(
  -> 'a'
  -> 'b'
)

hoge ->
  'a'
,    ->
  'b'

hoge \
  ->
    'a'
, ->
    'b'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment