Question

Had to change this up. I have two arrays and I want to essentially concatenate them into one array.

 completearray:= completearray, temparray."concatenate the new array to the existing one"

How do I get this working please? Thanks.

Was it helpful?

Solution

Your code works in Squeak, so what is the problem?

anArray := #(1 2 3 4).
anotherArray := #(5 6 7).
anArray, anotherArray "Returns #(1 2 3 4 5 6 7)"

OTHER TIPS

if your code doesn't run, you probably don't have an Array object in "completearray", but instead have an object that doesn't respond to #, (i.e. nil doesn't respond to #,).

you are adding a character ($,), but you have to add a string with #, (cancat). try: yourString , ','

I don't know, why it may not work in your version of VisualWorks, but you can try to do this:

completearray addAll: temparray.

Source, just in case:

addAll: collection
    ^ collection
        do: [ :element | self add: element];
        yourself
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top