Copy link to clipboard
Copied
Hi there,
I'm having a hard time using the CSS auto compilation for SCSS. I have just one scss file and it has been working like a charm in my current project for the last month or so, but now I just get the error:
NoMethodError: undefined method `[]' for nil:NilClass
on line – – and column 1
I can't see any error in my scss what so ever, and Dreamweaver don't give me any input that something should be wrong either. How do I debug this?!
Copy link to clipboard
Copied
More info please. What does line -- look like?
Copy link to clipboard
Copied
I don't really understand which line is even "line --", which makes the error a bit hard for me to understand and find 😕
Copy link to clipboard
Copied
This error occurs when you are trying to access an array value that does not exist. The error message "undefined method `[]' for nil:NilClass" indicates that the variable you are trying to access is nil, or undefined.
To solve this error, you can do the following:
For example, instead of writing:
variable = nil
value = variable[0]
You can write:
variable = nil
value = variable&.[](0)
This will ensure that if variable is nil, it will return nil without raising an error.