How do you add an element to a List in Scala 2.7.5, without creating a new List and without using a deprecated solution.
How do you add an element to a List in Scala 2.7.5, without creating
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That does not exist, and it will never exist.
Use
:::Or, if
listis avar,It does not create a new
List(though, it creates a new::, also known as cons), and it adds an element to it.If you want to append elements to a sequence without creating a new sequence, use a mutable data structure.