Coffeescript unmatched outdent error

NielMalhotra picture NielMalhotra · Jan 11, 2013 · Viewed 36.4k times · Source

I'm getting the error SyntaxError: Unmatched OUTDENT on line 9 when I try to compile the following coffeescript code. I'm not sure what I'm doing wrong. the indentation seems to be right, and I have everything where I want it.

row_possibilities = (grid) ->
  for rows in [0..8] by 1
    for columns in [0..8] by 1
      if(Array.isArray(grid[rows][columns])
        for possible_val in grid[rows][columns] by 1
          grid = unique_row_possibility(grid, rows, columns, possible_val)
          if(Array.isArray(grid[rows][columns]) == false)
            break
  return grid

What the code is supposed to do is run the three for loops and breaks the innermost for loop if a certain condition happens.

After all the for loops run. I want to return the variable grid. I've double checked the spacing, and I tried it out on repl.it, but I can't figure it out.

Answer

Jesse Vogt picture Jesse Vogt · Jan 11, 2013

A bit tough to see but it appears that you are missing a closing parenthesis on line 4:

if(Array.isArray(grid[rows][columns])

In general, for this particular error, the problem will almost always lie with indention or unbalanced parenthesis or brackets/braces.