2016-08-25 68 views
0

我需要更新一個數組的元素,而無需創建一個新的數組再次更新數組的元素在斯卡拉

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) 

我想辦法做到這一點,而不使用產量

+0

我很好奇,什麼樣的數據元素,在'probeFileLines',包含引號僅_after_調用'的toString()'就可以了? – jwvh

回答

1

您可以修改一個Array,到位,像這樣:

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