From af5227f03ba2ce411dd5677076e884f0c8eb5e06 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Sun, 31 Jan 2021 07:34:27 +0200 Subject: [PATCH] Mention `List.[Range]` in the docs (#870) --- doc/site/modules/core/list.markdown | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/site/modules/core/list.markdown b/doc/site/modules/core/list.markdown index 94cc9d0d..879de2ed 100644 --- a/doc/site/modules/core/list.markdown +++ b/doc/site/modules/core/list.markdown @@ -160,7 +160,17 @@ var list = ["a", "b", "c"] System.print(list[1]) //> b -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. + +
+var list = ["a", "b", "c"]
+System.print(list[0..1]) //> [a, b]
+
+ +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