What is the correct way to get a subarray in Scala?

后端 未结 3 1507
南方客
南方客 2020-12-23 14:29

I am trying to get a subarray in scala, and I am a little confused on what the proper way of doing it is. What I would like the most would be something like how you can do

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 14:46

    You can call the slice method:

    scala> Array("foo", "hoo", "goo", "ioo", "joo").slice(1, 4)
    res6: Array[java.lang.String] = Array(hoo, goo, ioo)
    

    It works like in python.

提交回复
热议问题