我的一个
函数产生一个数组 – 一组有序的,连续编号的记录.但据我所知,
Scala Array是一个可变集合,而
功能方法表明在一般情况下返回不可变集合会更有意义.所以我只是
调用Array.toIndexedSeq来返回IndexedSeq而不是Array.这可以被认为是正确的做法吗?它是否会引入任何可能影响
功能和结果使用的明显行为,并且可能被认为是不合需要的?这个问题有更好的做法吗?
Can this be considered a correct thing to do?
是.
Doesn’t it introduce any inobvIoUs behavIoUr which can influence the
function and the result usage and be probably considered undesirable?
不,不是我所知道的.
Are there any better practices for the issue?
如果可能的话,尝试完全消除数组的使用,除非性能是最重要的.