Getting last element of an array in Julia – last() Method Last Updated : 26 Mar, 2020 Improve Improve Like Article Like Save Share Report The last() is an inbuilt function in julia which is used to return the last element of the specified iterable collection. Syntax: last(coll) Parameters: coll: Specified iterable collection. Returns: It returns the last element of the specified iterable collection. Example 1: # Julia program to illustrate # the use of last() method # Getting the last element of # the specified iterable collection # or 1D array println(last(1:2:3)) println(last(5:10)) println(last([3, 5, 7, 9])) println(last([2, 4, 6, 8])) Output: 3 10 9 8 Example 2: # Julia program to illustrate # the use of last() method # Getting the last element of # the specified 2D and 3D array println(last([3 5; 7 9])) println(last(["a" "b"; "c" "d"])) println(last(cat([1 2; 3 4], [5 6; 7 8], [2 2; 3 4], dims = 3))) println(last(cat(["a" "b"; "c" "d"], ["e" "f"; "g" "h"], ["i" "j"; "k" "l"], dims = 3))) Output: Like Article Suggest improvement Next Getting first element of an array in Julia - first() Method Share your thoughts in the comments Add Your Comment Please Login to comment...