An array of dictionary arrays is a syntax error?

In my project i have a property which is an array of dictionary arrays….
Xojo is calling this a syntax error.

Change (-1) to () and remove the parenthesis after Dictionary.

1 Like

There isn’t a way to declare an array of arrays in Xojo. However, you can simply assemble them:

Var someSubArray() as Dictionary

someSubArray.Add new Dictionary

Var myArrays() as Variant

myArrays.Add someSubArray

Var theRetrievedArray() as Dictionary

theRetrievedArray=myArrays(0)

HOWEVER.

This way lies madness. While it will work, this code has a huge red flag: use of Variants. I’d suggest you look into creating a class to hold the Dictionaries and assemble an array of those instead.

2 Likes

In the current VB.Net they solve it using the Generic List (an array of “whatever” (any type) ) and the “whatever” is another List, now of Dictionaries (also typed, but usually it is string for keys and object (accept anything, as anything is an Object, meaning literally anything) for contents), like:

Dim arrayOfArrayOfDictionaries As New List(Of List(Of Dictionary(Of String, Object)))()

A future Xojo should adhere something like that. Generics and Boxing/unboxing (implicit value<=>reference conversion) for an everything is an Object and deprecate (and kill in the future) Variants (easily changed to the type Object)