forked from Mirror/wren
Also noted that the ```add``` method returns the added item.
This commit is contained in:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user