View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

RawArrray::collect should use Array.new (SC3d4)

RawArray::collect creates a kind of Collection and uses it to collect the results of iterating a function on each element of itself. If the Collection created is of the same species as the RawArray that "collect" iterates on, then only functions that return the same kind of elements contained in the initial RawArray can be used. That is,
SymbolArray[\a, \b, \c].collect({ arg s; s.asString })

will not work.

To correct this, RawArray::collect should use
Array.new
instead of
this.species.new


Fix:
+ RawArray {
	collect { arg function;
		var i, res;
		res = Array.new(this.size);
		this.do({ arg elem, i; res.add(function.value(elem, i)) })
		^res;
	}
}


Download this patch as SC file: extRawArrayCollect.sc

Back to Bugs and Fixes
Back to SuperCollider swiki


Link to this Page