Coffeescript unmatched outdent error

2019-03-14 05:25发布

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.

1条回答
何必那么认真
2楼-- · 2019-03-14 06:05

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.

查看更多
登录 后发表回答