I am having two arrays. Size of first array is larger than second one.
var first = (1 to 20).toArray
var second = (1 to 5).toArray
I want to Replace first n elements of first array with the elements of second array. Where n is length of second array. Using For loop I can easily do this in following way
var n = second.length
for(i <- 0 until n)
{
first(i) = second(i)
}
I want to ask is there any other way to perform same operation in Scala in more functional way?
copyToArraylike,second.copyToArray(first). Also, for what you need you could replacevarwithval.Arrayin the first place, just sayin'...