Skip to content

Instantly share code, notes, and snippets.

@gonzedge
Created December 16, 2011 19:17
Show Gist options
  • Save gonzedge/1487491 to your computer and use it in GitHub Desktop.
Save gonzedge/1487491 to your computer and use it in GitHub Desktop.
CoffeeScript: The '=>' operator
outerFunctionWithCallback = (options, callback) ->
# Do something with options
callback()
theFunction = ->
self = @
@doFirstThing = -> # ...
@doSecondThing = -> # ...
initialize = ->
self.doFirstThing();
self.doSecondThing();
outerFunctionWithCallback {}, initialize;
var outerFunctionWithCallback = function(options, callback) {
/* Do something with options */
callback();
};
var theFunction = function(){
var self = this;
this.doFirstThing = function() { /* ... */ };
this.doSecondThing = function() { /* ... */ };
var initialize = function() {
self.doFirstThing();
self.doSecondThing();
};
outerFunctionWithCallback({/* options */}, initialize);
};
outerFunctionWithCallback = (options, callback) ->
# Do something with options
callback()
theFunction = ->
@doFirstThing = -> # ...
@doSecondThing = -> # ...
initialize = =>
@doFirstThing();
@doSecondThing();
outerFunctionWithCallback {}, initialize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment