0

Say we have a simpleList and want to print a specified list range. How is this done in Scala?

val simpleList= List(1, 2, 3, 4, 5)
println(simpleList(0))  //> Value 1
println(simpleList(0:4)) //> No output
Bob Hopez
  • 773
  • 4
  • 10
  • 28

1 Answers1

0

Found an indication here:

println(numberList.slice(0,4))  //> List(1, 2)
Community
  • 1
  • 1
Bob Hopez
  • 773
  • 4
  • 10
  • 28