I did initialize the array.
in the constructor I have:
let someArray = Array.new(ARRAY_SIZE);
I am currently building a snake game. and I need to handle arrays as the snake moves.
I wrote a method shifting right the array cells and adding to the array at cell 0.
That method works just fine.
I also have a method that returns the head of the array i.e. value at cell 0.
The getter method has the following command:
This call happens after the array was handled so there is no problem with the array itself.
But I still get a segment exception. Even though I know for a fact the array is initialized in scope and holds values.
Why would this happen? I have spent a few days now trying to understand it. There seems to be nothing wrong and no object has been deallocated. It seems that every time I try to pass the contents of someArray between my classes I get a segment exception...
Nothing obviously wrong. It still feels like the getter is being called with a null pointer. Check that it is being called as a method. It's easy to forget that Jack doesn't automatically use method semantics when calling between an class's methods.
If you want to, you may send me your program and I can take a look at it.