Reputation:
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
Reputation: 76333
You have to use for (String name in _objectPools.keys)
.
Upvotes: 2