Skip to content

Instantly share code, notes, and snippets.

@gonzalo123
Created October 13, 2011 18:51
Show Gist options
  • Save gonzalo123/1285122 to your computer and use it in GitHub Desktop.
Save gonzalo123/1285122 to your computer and use it in GitHub Desktop.
Example static and non static functions
class Dummy
@helloStatic: (name)->
"hello #{name} (static)"
hello: (name) ->
"hello #{name}"
alert Dummy.helloStatic("Gonzalo")
dummy = new Dummy
alert dummy.hello("Gonzalo")
var Dummy, dummy;
Dummy = (function() {
function Dummy() {}
Dummy.helloStatic = function(name) {
return "hello " + name + " (static)";
};
Dummy.prototype.hello = function(name) {
return "hello " + name;
};
return Dummy;
})();
alert(Dummy.helloStatic("Gonzalo"));
dummy = new Dummy;
alert(dummy.hello("Gonzalo"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment