From 568b4322066208b59be2525524a4a641b0e20973 Mon Sep 17 00:00:00 2001 From: Kevin McDermott Date: Sat, 23 Nov 2024 18:12:12 +0000 Subject: [PATCH] Update documentation for list/first. Signed-off-by: Kevin McDermott --- ext/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ext/README.md b/ext/README.md index 07e544d0..511d0a47 100644 --- a/ext/README.md +++ b/ext/README.md @@ -500,6 +500,36 @@ Examples: ].sortBy(e, e.score).map(e, e.name) == ["bar", "foo", "baz"] +### Last + +**Introduced in the OptionalTypes library version 2** + +Returns an optional with the last value from the list or `optional.None` if the +list is empty. + + .list() -> + +Examples: + + [1, 2, 3].list().value() == 3 + [].last().orValue('test') == 'test' + +This is syntactic sugar for list[list.size()-1]. + +### First + +**Introduced in the OptionalTypes library version 2** + +Returns an optional with the first value from the list or `optional.None` if the +list is empty. + + .first() -> + +Examples: + + [1, 2, 3].first().value() == 1 + [].first().orValue('test') == 'test' + ## Sets Sets provides set relationship tests.