Forums

Array.clear method

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Array.clear method

Postby Ajrat » Fri Dec 21, 2012 3:45 am

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?
Sorry for my bad English.
Ajrat
 
Posts: 8

Re: Array.clear method

Postby Charles » Fri Dec 21, 2012 3:57 pm

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 26 guests