From 8a0dd88f1073f8fac9b2db022027eae3752dffd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Wed, 30 Aug 2023 13:31:37 +0200 Subject: Make zip variadic (#2041) --- docs/reference/types.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'docs/reference') diff --git a/docs/reference/types.md b/docs/reference/types.md index 09cc2909..1136bd27 100644 --- a/docs/reference/types.md +++ b/docs/reference/types.md @@ -1033,13 +1033,17 @@ for loop. - returns: array ### zip() -Zips the array with another array. If the two arrays are of unequal length, it -will only zip up until the last element of the smaller array and the remaining -elements will be ignored. The return value is an array where each element is yet -another array of size 2. +Zips the array with other arrays. If the arrays are of unequal length, it will +only zip up until the last element of the shortest array and the remaining +elements will be ignored. The return value is an array where each element is +yet another array, the size of each of those is the number of zipped arrays. -- other: array (positional, required) - The other array which should be zipped with the current one. +This method is variadic, meaning that you can zip multiple arrays together at +once: `(1, 2, 3).zip((3, 4, 5), (6, 7, 8))` returning: +`((1, 3, 6), (2, 4, 7), (3, 5, 8))`. + +- others: array (variadic) + The other arrays which should be zipped with the current one. - returns: array ### fold() -- cgit v1.2.3