From a36a86ab253226c4bddcd422207055d7eb9e38c2 Mon Sep 17 00:00:00 2001 From: Adrian Sieber <36796532+ad-si@users.noreply.github.com> Date: Sat, 13 Jan 2024 12:22:24 +0100 Subject: [PATCH] Improve documentation for `slice 0 -1` `pop()` in JavaScript returns the popped of element and not the shortened array. Clarify that `slice 0 -1` actually returns the array without the last element. --- src/Array.elm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Array.elm b/src/Array.elm index 8c180605..8bb1ff1e 100644 --- a/src/Array.elm +++ b/src/Array.elm @@ -666,8 +666,12 @@ the end of the array. slice 1 -1 (fromList [0,1,2,3,4]) == fromList [1,2,3] slice -2 5 (fromList [0,1,2,3,4]) == fromList [3,4] -This makes it pretty easy to `pop` the last element off of an array: -`slice 0 -1 array` +This makes it easy to get a new array without the last element. + + slice 0 -1 (fromList [0,1,2]) == fromList [0,1] + +Like `pop()` in JavaScript, but returning the new array +instead of the popped of element. -} slice : Int -> Int -> Array a -> Array a slice from to array =