Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why is the + operator for List deprecated in Scala?

deprecated list operator Scala
0
Posted

Why is the + operator for List deprecated in Scala?

0

Class Listdoes not offer an append operation because the time it takes to append to a list grows linearly with the size of the list, whereas prepending with :: takes constant time. Your options if you want to build a list by appending elements is to prepend them, then when you’re done call reverse; or use a ListBuffer, a mutable list that does offer an append operation, and when you’re done call toList.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.