In scala, what is a good way to loop through a linked list(scala.collection.mutable.LinkedList) of objects? For example, I want to have ‘for’ loop traverse through each object on the linked list and process it.
In scala, what is a good way to loop through a linked list(scala.collection.mutable.LinkedList) of
Share
With foreach:
or, if your processing of each object returns a new value, use map:
Some people prefer for comprehensions instead of
foreachandmap. They look like this: