December 03, 2011
Coffeescript is so hot right now and everyone loves it and so do I. The syntax for creating classes without having to use
prototype.whatever() is a joyous abstraction the more I get into it.
class Taco constructor: (@filling) -> @filling = 'carnitas' unless @filling?
When I started organizing classes in separate files (
burrito.coffee.js, etc.) I ran into a little bit of trouble creating instances of those classes in my main
application.coffee.js file. Turns out I needed to declare my classes on the global
window object to make it work.
Then you shouldn’t have problems instantiating those classes from other files that are part of your application.