Maps of Int[]
Monkey Forums/Monkey Programming/Maps of Int[]
| ||
| I can't seem to declare a map of an array of ints... in BMax you could int arrays in maps no problem but in monkey I've had no luck. I've tried: Local amap:StringMap<Int[]> = New StringMap<Int[]> (syntax error - expecting identifier) Local amap:StringMap<IntObject[]> = New StringMap<IntObject[]> (syntax error - expecting '>') Local amap:Map<String,Int[]> = New Map<String,Int[]> (syntax error - expecting identifier) any ideas? |
| ||
| try local i:IntMap=new IntMap ? EDIT oh an array, hmm dont know if its possible |
| ||
| You could always wrap the Int array in a class. That should work. |
| ||
| yeah, I suppose I will have to do that. |
| ||
| See: http://monkeycoder.co.nz/Community/post.php?topic=1408&post=12717 Your best bet is: Local mymap:StringMap<List<IntObject>> = New StringMap<List<IntObject>> |
| ||
| thanks, List won't work since I need array indexing... but Stack would. I'm going to go with a custom class though. |
| ||
Use Diddy's ArrayList classes then.Import diddy
Function Main:Int()
Local mymap:StringMap<IntArrayList> = New StringMap<IntArrayList>
mymap.Set("foo", New IntArrayList)
mymap.Get("foo").Add(42)
Print mymap.Get("foo").Get(0)
End |