I have a member variable in a class:
val options = mutable.LinkedList[SelectOption]()
I latter then populate this list from the database.
At some point I want to refresh the list. How do I empty it?
In java:
options.clear();
Is there an equivalent in Scala?
Do not use
LinkedList. That is a low level collection which provides a data structure that can be manipulated at user’s will… and responsibility.Instead, use one of the
Bufferclasses, which have theclearmethod. This method, by the way, is inherited from theClearabletrait, so you can just look at classes that extendClearable.