-1

In Python, you can get a sublist from a certain starting index to the end using x[i:], for example if x = [1, 2, 3, 4], x[1:] would give you [2, 3, 4]. I was wondering what is the equivalent way to do this in Scala.

MetallicPriest
  • 29,191
  • 52
  • 200
  • 356

2 Answers2

2

Use drop for this case:

x.drop(1)

For the particular case of 1, we usually use x.tail instead.

sjrd
  • 21,805
  • 2
  • 61
  • 91
1

It's called drop and you use it like xs.drop(i).