From 0c94d2b34e77edbd116c9f7be591ca710363b844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Tue, 18 Jul 2023 15:23:56 +0200 Subject: Adding `dedup` to `array` (#1738) --- docs/reference/types.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs/reference') diff --git a/docs/reference/types.md b/docs/reference/types.md index 28646cd2..d602bc3e 100644 --- a/docs/reference/types.md +++ b/docs/reference/types.md @@ -966,6 +966,21 @@ Return a new array with the same items, but sorted. If given, applies this function to the elements in the array to determine the keys to sort by. - returns: array +### dedup() +Returns a new array with all duplicate items removed. + +Only the first element of each duplicate is kept. + +```example +#{ + (1, 1, 2, 3, 1).dedup() == (1, 2, 3) +} +``` + +- key: function (named) + If given, applies this function to the elements in the array to determine the keys to deduplicate by. +- returns: array + # Dictionary A map from string keys to values. -- cgit v1.2.3