Mahdi
Mahdi

Reputation: 817

Updating an elements of an array in scala

I need to update the elements of an array without creating a new array again

val funcRemoveQuotes=(x:String)=>
  {
    x.substring(1,x.length-1)

  }
probeFileLines.map(x => x._2.toString()).map(x => x.split(","))
.map(//.need to apply funcRemoveQuotes on each element of array)

I want to do it by way without using yield

Upvotes: 0

Views: 688

Answers (1)

jwvh
jwvh

Reputation: 51271

You can modify an Array, in place, like so:

arr.indices.foreach(x => arr(x) = funcRemoveQuotes(arr(x)))

Upvotes: 1

Related Questions