不得不改变这一点。我有两个数组,我想基本上将它们连接成一个数组。
completearray:= completearray, temparray."concatenate the new array to the existing one"
请问我该如何工作?谢谢。
不得不改变这一点。我有两个数组,我想基本上将它们连接成一个数组。
completearray:= completearray, temparray."concatenate the new array to the existing one"
请问我该如何工作?谢谢。
您的代码在 Squeak 中工作,那么问题是什么?
anArray := #(1 2 3 4).
anotherArray := #(5 6 7).
anArray, anotherArray "Returns #(1 2 3 4 5 6 7)"
如果您的代码没有运行,您可能在“completearray”中没有 Array 对象,而是有一个不响应 #, 的对象(即 nil 不响应 #,)。
您正在添加一个字符 ($,),但您必须添加一个带有 #, (cancat) 的字符串。试试:你的字符串,','
我不知道,为什么它在您的 VisualWorks 版本中可能不起作用,但您可以尝试这样做:
completearray addAll: temparray.
来源,以防万一:
addAll: collection
^ collection
do: [ :element | self add: element];
yourself