Scala list take with offset

data-structures, list, scala

Solution

I think `slice` is exactly what you're looking for

scala> val source = List("1", "2", "3", "4", "5", "6", "7")
source: List[String] = List(1, 2, 3, 4, 5, 6, 7)

scala> source.slice(2, 4)
res0: List[String] = List(3, 4)

Problem

For example I have `val source = List("1", "2", "3", "4", "5", "6", "7")` and I need get 3 elements start with second element. expected `List("2","3")` or `List("3","4")`. Is there any methods or any data structure with this ability?

Original source