Monkey List to BMX List
BlitzMax Forums/BlitzMax Programming/Monkey List to BMX List
| ||
Unable to use MonkeyMax, I have the following List that I need to convert to BMX from Monkey code:Class Parts Field x:Float Field y:Float Field z:Float End Class Class Members Field JointsList:List<Parts> Method New() JointsList = New List<Parts>() End Method End Class |
| ||
This should be it:Type Parts Field x:Float Field y:Float Field z:Float EndType Type Members Field jointsList:TList Method New() jointsList = New TList EndMethod EndType Full example: |
| ||
Thanks therevills. I will try this out! :) |
| ||
One question, so the <Parts> can be ingored in Blitzmax? |
| ||
Yee. Tlist is more generic. It just stores "object"s. Bye Ron |
| ||
The <Parts> are part of "Generics" within MX, it forces the list to only contain objects of that type, eg JointsList = New List<Parts>() can only hold Parts objects. A TList as Ron has said is more generic... it can hold any type of object, for example you can add different objects and Strings to the same list, but if you access them you will need to cast to the assigned variable's type. |
| ||
You only need to cast them, if you access them via "ValueAtIndex()".For local bl:onlyThisType = EachIn list ... Next Only iterates over list entries of type "onlyThisType" (or extending from it). bye Ron |
| ||
Yeah I forgot that Eachin would only return the object type specified.. Heres an example of what Ron is saying: Of course you would want to be a bit smarter and use inheritance: |
| ||
Thanks guys, I have to checkout what you have given here and hopefully it would be simple enough with that <> and List part that is throwing this issue. So is Class just equivalent to BMX Type? |
| ||
So is Class just equivalent to BMX Type? Yes... but within BMX you cant use interfaces without doing a kludge. |