Skip to content

Instantly share code, notes, and snippets.

@stoplion
Created October 10, 2012 16:42
Show Gist options
  • Save stoplion/3866787 to your computer and use it in GitHub Desktop.
Save stoplion/3866787 to your computer and use it in GitHub Desktop.
coffeescript arg, callback pattern
func = ($names = {}, $callback='') ->
$proper_names = ("Mr. #{$name}" for $name of $names)
#$callback($proper_names) unless $callback?
if $callback
$callback($proper_names)
else
alert 'no callback given'
func {'bill', 'john'}, ($p_names) -> alert "i love #{$p_names}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment