user905864
user905864

Reputation:

Class '_LinkedHashMap<String, ObjectPool>' has no instance getter 'iterator'

so I got a chunk of code below:

...

static final Map<String, ObjectPool> _objectPools = new Map<String, ObjectPool>();

static IPoolable get(Type objectType)
{
  for (String name in _objectPools) // <-- This one throws an error
  {
    if (_objectPools[name].runtimeType == objectType)
    {
      return _objectPools[name].alloc();
    }
  }
}

...

and it throws an error "Breaking on exception: Class '_LinkedHashMap' has no instance getter 'iterator'." Last time I checked it's the for loop that throws me the error (as commented in the code) but I don't have a clue what causes it or any workaround for it. I also have tested that the _objectPools is filled at least one element so it should make a loop, but it doesn't.

any idea? Thanks!

Upvotes: 1

Views: 1596

Answers (1)

Alexandre Ardhuin
Alexandre Ardhuin

Reputation: 76333

You have to use for (String name in _objectPools.keys).

Upvotes: 2

Related Questions