From 7cc7c715c9ed23daa85e0bb1ba44c5acc5a4f108 Mon Sep 17 00:00:00 2001 From: underscorediscovery Date: Tue, 5 Feb 2019 18:18:38 -0800 Subject: [PATCH] docs; list; add + operator documentation --- doc/site/lists.markdown | 11 +++++++++++ doc/site/modules/core/list.markdown | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/site/lists.markdown b/doc/site/lists.markdown index 6e5bdd73..d47c22c8 100644 --- a/doc/site/lists.markdown +++ b/doc/site/lists.markdown @@ -89,6 +89,16 @@ back. Doing so counts back from the size of the list *after* it's grown by one: letters.insert(-2, "e") // Counts back from size after insert. System.print(letters) //> [a, b, c, e, d] +## Adding lists together + +Lists have the ability to be added together via the `+` operator. This is often known as concatenation. + + :::wren + var letters = ["a", "b", "c"] + var other = ["d", "e", "f"] + var combined = letters + other + System.print(combined) //> [a, b, c, d, e, f] + ## Removing elements The opposite of `insert` is `removeAt`. It removes a single element from a @@ -111,5 +121,6 @@ If you want to remove everything from the list, you can clear it: hirsute.clear() System.print(hirsute) //> [] +

Maps → ← Values diff --git a/doc/site/modules/core/list.markdown b/doc/site/modules/core/list.markdown index 60ac3945..ccac8f4f 100644 --- a/doc/site/modules/core/list.markdown +++ b/doc/site/modules/core/list.markdown @@ -110,3 +110,13 @@ backwards from the end of the list where `-1` is the last element. System.print(list) //> [a, new, c] It is a runtime error if the index is not an integer or is out of bounds. + +## **+**(other) operator + + Appends a list to the end of the list (concatenation). `other` must be a `List`. + + :::wren + var letters = ["a", "b", "c"] + var other = ["d", "e", "f"] + var combined = letters + other + System.print(combined) //> [a, b, c, d, e, f]