2

Is there any built-in function in Scala that takes a part of an array and creates a new array from this part? Something that makes the following pseudo-code:

newarr = oldarr[3:5]

meaning, newarr is an array of 3 elements, that:

newarr[0]=oldarr[3]
newarr[1]=oldarr[4]
newarr[2]=oldarr[5]
1

1 Answer 1

7
val newarr = oldarr.slice(3,6) // from index 3 until (not including) index 6

Study the Standard Library. It's amazing what you'll find there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.