-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
  • 27,365
  • 43
  • 180
  • 324

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,155
  • 2
  • 59
  • 85
1

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