You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently you can only push a single value at a time.
However some targets like JavaScript support pushing multiple values at once, and this functionality could be easily implemented into hxcpp too.
Allowing multiple values to be pushed at once would improve performance, as platforms could preallocate the required space for the requested amount of items, rather than reallocating each time a value is pushed
This feature seems like a good candidate to add to Haxe 5.x.x
If we don't want to risk breaking programs by making it push(...val:T), we could make a new function named pushAll(...val:T)
Heres how to do it for different targets:
Javascript:
array.push(...values);// takes up to 65535 arguments
Python:
array.extend(values) # takes an array
Java:
// if ArrayList is used internallyarray.addAll(values); // takes an array
PHP:
array_push($array, ...$values); // takes any amount of arguments
The text was updated successfully, but these errors were encountered:
I think I would propose an insertMany(pos:Int, args:Array<T>):Void; and then you can still have your pushAll as a special case of that, via static extension.
No other target supports insert multiple values at once, to my knowledge and more targets support pushing multiple. If we want i would think it would be better to have pushMultiple/pushMany and insertMultiple/insertMany
Currently you can only push a single value at a time.
However some targets like JavaScript support pushing multiple values at once, and this functionality could be easily implemented into hxcpp too.
Allowing multiple values to be pushed at once would improve performance, as platforms could preallocate the required space for the requested amount of items, rather than reallocating each time a value is pushed
This feature seems like a good candidate to add to Haxe 5.x.x
If we don't want to risk breaking programs by making it
push(...val:T)
, we could make a new function namedpushAll(...val:T)
Heres how to do it for different targets:
Javascript:
Python:
Java:
PHP:
The text was updated successfully, but these errors were encountered: