Logo

Programming-Idioms

  • Kotlin
  • Haskell
x = last items

Crashes if items is empty
foo :: [a] -> Maybe a
foo [] = Nothing
foo xs = Just $ last xs

x = foo items

items is a list of homogeneous elements
var x = items.last()
X := Items'Last

X must be declared earlier.

New implementation...