trait Quizful[T] {
 def fetchList: List[T]
}

// consumer side
someQuizful.fetchList
If the List returned above is mutable, what does that say about the Quizful interface?
Explanation
Immutable data structures are facts that can be compared and reasoned about. Mutable things are error-prone buckets. You should never use a mutable data structure unless you're able to defend it and there are really, really few places in which a mutable data structure​ is defensible.
So there you have it - a public API exposing a mutable data-structure is an abomination of nature, leading to problems that can be worse than what happens when doing manual memory management

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback