A bug, caused by local variable with the same name as a global one
in
Programming Questions
•
5 months ago
I had a very strange bug recently. I named a String array "articles[]". Then in setup I loaded a txt file into it
- articles=loadStrings("articles.txt");
Then I tried to access it from setup and draw like this:
- println(articles);
It worked fine. But when I called println inside a function that was inside a class I got "null".
Then I changed the name of "articles[]" array and everything worked fine. What could cause this bug?
*UPDATE*
Sorry, I found it. Looks like I had a String named "articles" in my class, so when I called println inside of a that class I got values of a local undefined array bu not values of a global one))
1