Reputation: 115
I've started a little game in CoffeScript using canvas. My problem is this error:
coffee -c -o lib/ src/
/src/interface.coffee:8:48: error: unexpected end of input
@ctx.clearRect 0, 0, @size[0], @size[1]
^
I've rewrote it many times but it still don't want to compile. Here is the code:
class Interface:
constructor : (id) ->
@canvas = document.getElementById "#{id}"
@ctx = @canvas.getContext "2d"
@size = [@canvas.width, @canvas.height]
clear : () ->
@ctx.clearRect 0, 0, @size[0], @size[1]
Oh, and can someone tell me what exactly this error means?
Thank you in advance.
Upvotes: 0
Views: 214
Reputation: 21946
Its the colon after Interface. An easy way to debug that error for future reference:
Step 1: paste problem code into the 'Try CoffeeScript' part of the coffeescript website to repro the error.
Step 2: erase or comment-out lines until the error goes away and the code compiles
Step 3: the last line you erased was the error.
Step 4: find the error(s) in that line and fix.
Step 5: repeat as necessary.
This is how I figured out what the problem was. This process also works well for the 'Unmatched Outdent' error.
Upvotes: 2