ArrayCollection.getItemAt() doesn’t return null

Just a second ago I changed an Array property into an ArrayCollection, when I tested my project again a RangeError was thrown telling me that I was trying to access an index that was out of bounds (occuring at .getItemAt()).
Now this itself didn’t surprise me alot, but what did surprise me was that I hadn’t gotten this Error back when my property was still an Array.

I figured that it must be the fact that an ArrayCollection uses actual methods, like getItemAt(). To varify my assumption I looked in the LiveDocs.

Strange enough the docs say that the return value for getItemAt() is “the item at that index, or null if there is none”.
I don’t think I can ever trust my old friend the LiveDocs again after lying to me about returning null and then stabbing me in the back with a RangeError..

5 Responses

Note that comments are displayed in reverse chronological order with topmost comments being freshest. Subscribe | Comment
  • berryblitz says so:
    February 2nd, 2008 | Quote

    We all know that Adobe Flex still have lots of errors that are quite weird that we don’t get on other tools. Maybe we give Flex some more time. Maybe on Adobe Flex 5 some of the “weird” issues would be solve.

  • Ruben says so:
    November 8th, 2007 | Quote

    ..but you do get a RangeError, right?

  • Andrew says so:
    November 8th, 2007 | Quote

    Actually, I have the same problem, if you try and test it against null it passes the test, and never returns null.

    (myArrayCollection.getItemAt(invalidLocation) == null) never returns false.

  • Ruben says so:
    October 26th, 2007 | Quote

    Hmm, maybe, but it still sounds kinda shady to me ;)

  • boon says so:
    October 26th, 2007 | Quote

    I think what the livedoc is trying to say is that if there is an object at that index, it will be returned, otherwise null is returned. But if you try to access things outside of the valid range, of course you should get an exception. It would be bad if the framework silently lets you do that without alarming you of your bug.

Leave a Reply