1
0
forked from Mirror/wren

Fix undocumented methods in the List class ( #878) (#883)

Also noted that the ```add``` method returns the added item.
This commit is contained in:
PureFox48
2021-01-31 05:21:07 +00:00
committed by GitHub
parent 16ddbb66f8
commit 96eb68bae3

View File

@ -22,7 +22,19 @@ Creates a new empty list. Equivalent to `[]`.
### **add**(item)
Appends `item` to the end of the list.
Appends `item` to the end of the list. Returns the added item.
### **addAll**(other)
Appends each element of `other` in the same order to the end of the list. `other` must be [an iterable](../../control-flow.html#the-iterator-protocol).
<pre class="snippet">
var list = [0, 1, 2, 3, 4]
list.addAll([5, 6])
System.print(list) //> [0, 1, 2, 3, 4, 5, 6]
</pre>
Returns the added items.
### **clear**()
@ -173,3 +185,13 @@ var other = ["d", "e", "f"]
var combined = letters + other
System.print(combined) //> [a, b, c, d, e, f]
</pre>
### **\***(count) operator
Creates a new list by repeating this one ```count``` times. It is a runtime error if ```count``` is not a non-negative integer.
<pre class="snippet">
var digits = [1, 2]
var tripleDigits = digits * 3
System.print(tripleDigits) //> [1, 2, 1, 2, 1, 2]
</pre>