Elise Langham (Elanit) wrote:

How do i create a jagged array in IronPython ?

I’ve tried various methods:

jagArray = Array[Array[int]]( ( (1,2), (1,2), (1,2,3), (1,2,3,4) ))

giving the error message: TypeError: expected Array[int], got tuple>

Yep - you created an array of arrays but passed in tuples (although it would be nice if that worked). Try:

jagArray = Array[Array[int]]( ( Array[int](1,2), Array[int](1,2), Array[int](1,2,3), Array[int](1,2,3,4) ))

Michael

also

jaggedLengths = Array[int]((1,2,3,4))

cinit = System.Array.CreateInstance(int, jaggedLengths)

cinit[0][0] = 3

giving the error message: IndexError: index out of range: 0

Is there another method for creating arrays?

Many thanks,

Elise

------------------------------------------------------------------------

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
http://www.ironpythoninaction.com/

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to