A function of mine produces an array – an ordered, contiguously numbered set of records. But as far as I know Scala Array is a mutable collection, while functional approach suggests it would make more sense to return an immutable collection in a general case. So I just call Array.toIndexedSeq to return an IndexedSeq instead of 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?
A function of mine produces an array – an ordered, contiguously numbered set of
Share
Yes.
No, not that I know of.
If possible, try to eliminate the use of array altogether, unless of course the performance is paramount.