Navigation
Synopsis Return the last element of a list, if any.
Function &T last(list[&T] lst) throws EmptyList
Usage import List;
Description Also see tail that returns a list of one or more of the last elements of a list.
Examples
rascal>import List;
ok
rascal>last([1]);
int: 1
rascal>last([3, 1, 4, 5]);
int: 5
rascal>last(["zebra", "elephant", "snake", "owl"]);
str: "owl"
rascal>tail([3, 1, 4, 5]);
list[int]: [1,4,5]

Questions
Question [1].
The type of last([11]) is

Question [2].
last(["Oregano", "Pincess Leia"]) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.