Use drop
to remove from the front and dropRight
to remove from the end.
def removeFirstAndLast[A](xs: Iterable[A]) = xs.drop(1).dropRight(1)
Example:
removeFirstAndLast(List("one", "two", "three", "four")) map println
Output:
two
three
Use drop
to remove from the front and dropRight
to remove from the end.
def removeFirstAndLast[A](xs: Iterable[A]) = xs.drop(1).dropRight(1)
Example:
removeFirstAndLast(List("one", "two", "three", "four")) map println
Output:
two
three