An array of lists
Monkey Forums/Monkey Programming/An array of lists
| ||
| Hello. I would like to make an array of 16 lists. Could someone explain how this is achieved? Thank you. |
| ||
Something like this:Strict
Function Main:Int()
Local arrayOfList:List<String>[16]
For Local i:Int = 0 Until arrayOfList.Length()
arrayOfList[i] = New List<String>
If i = 1
arrayOfList[i].AddLast("1")
arrayOfList[i].AddLast("2")
End
Next
For Local s:String = Eachin arrayOfList[1]
Print s
Next
Return 0
End* Updated code - Thanks Jesse |
| ||
| @therevills don't you mean: Local arrayOfList:List<String>[16] |
| ||
| |
| ||
check again.
Strict
Function Main:Int()
Local arrayOfList:List<String>[15]
For Local i:Int = 0 Until arrayOfList.Length()
arrayOfList[i] = New List<String>
If i = 1
arrayOfList[i].AddLast("1")
arrayOfList[i].AddLast("2")
End
Next
For Local s:String = Eachin arrayOfList[15]
Print s
Next
Return 0
End
Monkey Runtime Error : Array index out of range |
| ||
| Doesn't declaring 15 elements get you 15 elements (0..14)? [monkeycode] For Local s:String = Eachin arrayOfList[14] Print s Next [/monkeycode] That shows you the last list. |
| ||
| ^^ correct! |
| ||
| Hahahaha... my bad - Can I go home now :) (Sorry!) |
| ||
| take the rest of the day off. you've been working too hard. :) |
| ||
| That made my day. :D /slap therevills |
| ||
| /slap therevills I was waiting for you to make a reply! LOL! Leave me alone - "they" want to make IVR active / active with TMS!!!! |
| ||
| Thank you. I shall attempt this later today. |