Enide Studio

CoffeeScript Spaces and Tabs

17 September 2013

by Paul Verest

Do you see any problem with CoffeeScript code in this snippet?

Any catches?

class SpacesTabs
 constructor: (@name) ->
 hi: ->
	hi2: ->
 
 say: ->
  say2: ->

Well you might if you look at resulting JavaScript.

hi2 and say2 produced quite different result, though at the same second level.

The reason is that coffeescript compiler treats spaces and tabs in the same way. And it just counts number of spaces or tabs to define level within object.

Hopefully now on you will never spend time on such strange behavior.

Just enable Show whitespace characters when in doubt` or pay attention to outline, or (the best) check your actual javascript file.

Resources

Enide Monst(e)r is not yet released.

See sources as https://github.com/Nodeclipse/org.nodeclipse.examples

comments powered by Disqus