What is the method, using Delphi XE2, to call to add Array definition to a dwsUnit component at runtime?
MyDwsUnit.Arrays.Add returns a TCollectionItem, not TdwsArray, while adding an array definition at design time adds a TdwsArray instance!.
Default TCollection.Add method returns a TCollectionItem, even though it’s actually an instance of whatever items the collections manages (this isn’t specific to DWScript, it’s a Delphi VCL thing).
To simplify that, most subclassed collections in DWScript now reintroduce an Add method that will wrap the default one with a cast, so you don’t have to do the cast manually. So chances are you’re on older version of DWScript.
If you don’t want to update, you can just use
instead.