Skip to content

Instantly share code, notes, and snippets.

@Santarh
Created July 29, 2012 08:13
Show Gist options
  • Save Santarh/3196602 to your computer and use it in GitHub Desktop.
Save Santarh/3196602 to your computer and use it in GitHub Desktop.
CoffeeScript : class variable & instance variable
class C
@count = 0; # class variable
constructor: (num) ->
C.count += 1;
@hoge = num; # instance variable
console.log( C.count ); # => 0
s = new C(72);
console.log( C.count ); # => 1
t = new C(64);
console.log( C.count ); # => 2
console.log( s.hoge ); # => 72
console.log( t.hoge ); # => 64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment