Page 1 of 1

Array.clear method

PostPosted: Fri Dec 21, 2012 3:45 am
by Ajrat
Code: Select all
gothicBands = @['Tones on Tail', 'Bauhaus', 'Systers of Mercy']
Array.clear(gothicBands, 1, 2)
for gothicBand in gothicBands
    print '[gothicBand], ' stop


When I run the above, I experience...

error: Argument 1 of method "clear" expects type Array?, but
the call is supplying type String[].
Compilation failed - 1 error
Not running due to errors above.


I change the code. Then all is well

Code: Select all
gothicBands = @['Tones on Tail', 'Bauhaus', 'Systers of Mercy']
gothicBandsArr = Array.createInstance(Type.getType('System.String'), gothicBands.length)
for i in gothicBands.length
    gothicBandsArr.setValue(gothicBands[i], i)
Array.clear(gothicBandsArr, 1, 2)
for i in gothicBandsArr.getLength(0)
    print '[gothicBandsArr.getValue(i)], ' stop


Is there short a path without explicit work with Array class?

Re: Array.clear method

PostPosted: Fri Dec 21, 2012 3:57 pm
by Charles
This is not currently supported and it's not clear what Array.clear should do if the type is String or Controller vs. String? or Controller?.

Arrays are not heavily used in Cobra btw. Lists and MultiList (and other collections) are much more common.