From 9b38db0db511ae27d36cccc6546fa55b4b31427c Mon Sep 17 00:00:00 2001 From: Abdulazeez Abdulazeez Adeshina Date: Mon, 8 Oct 2018 19:24:20 +0100 Subject: [PATCH] Add the first and last element getter block. --- modules/simple/core/List.sim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/simple/core/List.sim b/modules/simple/core/List.sim index 0bc381dc..44f8b537 100644 --- a/modules/simple/core/List.sim +++ b/modules/simple/core/List.sim @@ -249,6 +249,19 @@ class List : Object __OBJECT + arr[a] end return __OBJECT + + /* Returns the first element of the List */ + + block first() + return __OBJECT[0] + end + + /* Returns the last element in the List */ + + block last() + return __OBJECT[lengthOf(__OBJECT)] + end + /* * Error block, needs to be private * So it won't be be accessed outside