Here’s a gotcha if you’re not careful when writing CoffeeScript. Notice the generated js code where constructor now returns this._cursor!!
#c.coffee
Cursor = (cursor) ->
this._cursor = cursor
Cursor = (cursor) ->
this._cursor = cursor
0 // c.js
1 // Generated by CoffeeScript 1.6.2
2 (function() {
3 var Cursor;
4
5 Cursor = function(cursor) {
6 return this._cursor = cursor;
7 };
8
9 }).call(this);
1 // Generated by CoffeeScript 1.6.2
2 (function() {
3 var Cursor;
4
5 Cursor = function(cursor) {
6 return this._cursor = cursor;
7 };
8
9 }).call(this);
Here’s the fix.
#c.coffee
Cursor = (cursor) ->
this._cursor = cursor
this
Cursor = (cursor) ->
this._cursor = cursor
this
0 // c.js
1 // Generated by CoffeeScript 1.6.2
2 (function() {
3 var Cursor;
4
5 Cursor = function(cursor) {
6 this._cursor = cursor;
7 return this;
8 };
9
10 }).call(this);
1 // Generated by CoffeeScript 1.6.2
2 (function() {
3 var Cursor;
4
5 Cursor = function(cursor) {
6 this._cursor = cursor;
7 return this;
8 };
9
10 }).call(this);