13 lines
364 B
Scala
13 lines
364 B
Scala
package ninetyNineScalaProblems
|
|
|
|
object Problem01:
|
|
def lastElement(list: List[Any]): Option[Any] =
|
|
list match
|
|
case Nil => None
|
|
case _ => Some(list(list.length - 1))
|
|
|
|
object Problem01Stdlib:
|
|
def lastElement(list: List[Any]): Option[Any] =
|
|
list match
|
|
case Nil => None
|
|
case _ => Some(list.last) |