Problem 01
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user