A Scala List is immutable. When you need to append elements in place, use scala.collection.mutable.ArrayBuffer.
val arr = scala.collection.mutable.ArrayBuffer(1, 2, 3)
arr += 4
// arr is now ArrayBuffer(1, 2, 3, 4)
Assignment
Follow the Coding Tutorial and append an item.
Hint
Use += with an ArrayBuffer.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check