1
0
forked from Mirror/wren

Mention List.[Range] in the docs (#870)

This commit is contained in:
Chayim Refael Friedman
2021-01-31 07:34:27 +02:00
committed by GitHub
parent 1720a20979
commit af5227f03b

View File

@ -160,7 +160,17 @@ var list = ["a", "b", "c"]
System.print(list[1]) //> b
</pre>
It is a runtime error if the index is not an integer or is out of bounds.
If `index` is a [Range](range.html), a new list is populated from the elements
in the range.
<pre class="snippet">
var list = ["a", "b", "c"]
System.print(list[0..1]) //> [a, b]
</pre>
You can use `list[0..-1]` to shallow-copy a list.
It is a runtime error if the index is not an integer or range, or is out of bounds.
### **[**index**]=**(item) operator