From 96eb68bae3ecf7ac94144e098aabcbc7974c7689 Mon Sep 17 00:00:00 2001 From: PureFox48 <64583745+PureFox48@users.noreply.github.com> Date: Sun, 31 Jan 2021 05:21:07 +0000 Subject: [PATCH] Fix undocumented methods in the List class ( #878) (#883) Also noted that the ```add``` method returns the added item. --- doc/site/modules/core/list.markdown | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/site/modules/core/list.markdown b/doc/site/modules/core/list.markdown index 2c389b65..89a04b12 100644 --- a/doc/site/modules/core/list.markdown +++ b/doc/site/modules/core/list.markdown @@ -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). + +
+var list = [0, 1, 2, 3, 4]
+list.addAll([5, 6])
+System.print(list) //> [0, 1, 2, 3, 4, 5, 6]
+
+ +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] + +### **\***(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. + +
+var digits = [1, 2]
+var tripleDigits = digits * 3
+System.print(tripleDigits) //> [1, 2, 1, 2, 1, 2] 
+