I have a long equation written in coffeescript, which turns in a function call when compiled to JavaScript:
CoffeeScript:
@u[idx] = @max(0, currU + t * ((@dU * ((@uu[right] + @uu[left] + @uu[bottom] + @uu[top]) -4 * currU) - d2) + currF * (1.0 - currU)))
JavaScript:
this.max(0, currU + t * ((this.dU * ((this.uu[right] + this.uu[left] + this.uu[bottom] + this.uu[top])(-4 * currU)) - d2) + currF * (1.0 - currU)));
The problem is this part:
((@uu[right] + @uu[left] + @uu[bottom] + @uu[top]) -4 * currU)
which turns into a function call:
((this.uu[right] + this.uu[left] + this.uu[bottom] + this.uu[top])(-4 * currU))
Can someone explain whats going on here.
You want this:
Which compiles to:
The silly little issue is the
-4, vs- 4.Without the space, the compiler assumes the
-4 * currUto be an argument to the ‘function’ ,(@uu[right] + @uu[left] + @uu[bottom] + @uu[top]).