feat: implement List concat operator + supporting Range and empty lists
Add `+` method to List class in core.wren that creates a new list by concatenating elements from both operands. Supports concatenation with Range objects and handles empty lists on either side. Includes comprehensive test cases in test/list/concat.wren covering list-list, list-range, and empty list combinations.
This commit is contained in:
@@ -8,4 +8,19 @@ class List {
|
||||
result = result + "]"
|
||||
return result
|
||||
}
|
||||
|
||||
+ that {
|
||||
var newList = []
|
||||
if (this.count > 0) {
|
||||
for (element in this) {
|
||||
newList.add(element)
|
||||
}
|
||||
}
|
||||
if (that is Range || that.count > 0) {
|
||||
for (element in that) {
|
||||
newList.add(element)
|
||||
}
|
||||
}
|
||||
return newList
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user