diff --git a/std/haxe/ds/ReadOnlyArray.hx b/std/haxe/ds/ReadOnlyArray.hx index b46122672b2..c1171653718 100644 --- a/std/haxe/ds/ReadOnlyArray.hx +++ b/std/haxe/ds/ReadOnlyArray.hx @@ -30,7 +30,7 @@ package haxe.ds; Other code holding a reference to the underlying `Array` can still modify it, and the reference can be obtained with a `cast`. **/ -@:forward(concat, copy, filter, indexOf, iterator, keyValueIterator, join, lastIndexOf, map, slice, contains, toString) +@:forward(copy, filter, indexOf, iterator, keyValueIterator, join, lastIndexOf, map, slice, contains, toString) abstract ReadOnlyArray(Array) from Array to Iterable { /** The length of `this` Array. @@ -42,4 +42,21 @@ abstract ReadOnlyArray(Array) from Array to Iterable { @:arrayAccess inline function get(i:Int) return this[i]; + + /** + Returns a new Array by appending the elements of `a` to the elements of + `this` Array. + + This operation does not modify `this` Array. + + If `a` is the empty Array `[]`, a copy of `this` Array is returned. + + The length of the returned Array is equal to the sum of `this.length` + and `a.length`. + + If `a` is `null`, the result is unspecified. + **/ + public inline function concat(a:ReadOnlyArray):Array { + return this.concat(cast a); + } } diff --git a/tests/unit/src/unit/issues/Issue9710.hx b/tests/unit/src/unit/issues/Issue9710.hx new file mode 100644 index 00000000000..622654987af --- /dev/null +++ b/tests/unit/src/unit/issues/Issue9710.hx @@ -0,0 +1,11 @@ +package unit.issues; + +import haxe.ds.ReadOnlyArray; + +class Issue9710 extends unit.Test { + function test() { + var a:ReadOnlyArray = [1]; + var b:ReadOnlyArray = [2]; + aeq([1, 2], a.concat(b)); + } +}