Deviopath › Go

Last Element

Easy · Slices

s[len(s)-1] is the last element. For an empty slice there is no last element: return 0 and do not panic.

Write Last(numbers) that returns the last int, or 0 if the slice is empty.

Next: Title Case Words