Null Object Access Error in this Code
Monkey Forums/Monkey Programming/Null Object Access Error in this Code
| ||
What do I start looking for to diagnose the error "Monkey Runtime Error : Null object access" generated by this code: [monkeycode] Class... Field defaultT:String[] =["jungle", "jungle2", "grassy"] Field mT:StringMap<MT> Method New... mT = New StringMap<MT> For Local t:Int = 0 Until defaultT.Length() Local newMT:MT = New MT(defaultT[t]) mT.Add(defaultT[t], newMT) Next [/monkeycode] The offending line is "Local newMT:MT = New MT(defaultT[t])" Thanks! |
| ||
If I try to reconstruct all the bits you've left out it works for me. Can you create a runnable example and also tell us what target you're seeing the issue with and what version of Monkey you're using? |
| ||
Hey, muddy! Thanks for the heads-up. I (apparently) worked it out (my program is functioning again after this refactor). Here's what I did: I figured it wasn't a problem with that actual line, but in the New() or OnCreate() code of some object elsewhere. I think that's actually what it was. I started splitting code, which helped me really hone in on where it was getting the error. Turns out I wasn't initializing an object somewhere. Anyway... my next question is... I'll put it in another thread, since this one is officially closed. P.S. I don't want to pressure you, but how about a new blog post? :-) Edit 1: DRAT! Something's not working again. I was doing some experimentation with New() and OnCreate() and messed it up again. Grrrrr... |