Hacker News new | ask | show | jobs
by nixme 5412 days ago
By default, CS compiles with a closure per file to prevent local variables from leaking to the global scope. So the purpose is to ensure the class is exported. If you put the following in a user.coffee file:

  class User
it would compile to:

  (function() {
    User = (function() {
      function User() {}
      return User;
    })();
  }).call(this);
while

  class @User
would compile to:

  (function() {
    this.User = (function() {
      function User() {}
      return User;
    })();
  }).call(this);
ensuring that User is available from any file (since the top-level this === window in the browser).