Loading...
Logo
Processing Forum
I had a very strange bug recently. I named a String array "articles[]". Then in setup I loaded a txt file into it 
Copy code
  1. articles=loadStrings("articles.txt");
Then I tried to access it from setup and draw like this: 
Copy code
  1. 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))

Replies(4)

The most likely cause is your code... which you don't show.

In other words: runnable example of this bug or it didn't happen.
Can you post the actual code?

EDIT: Cross-post... what he said! :)
You should provide an actual code to prove your point!
A very important detail is whether articles is a field or a local variable!
Another 1 is whether it got re-declared as a local variable when you used loadStrings()!
A class, you say?

I'm not an expert with classes (yet), but I would think that you didn't make an instance of the class.
Might that be the issue? I'm shooting in the dark, as are the others.

- MenteCode.