Say, I have a sequence of strings as an input and I want to get a new immutable Seq which consists of elements of the input and an item "c". Here are two methods that I've discovered to be working:
- assert(Seq("a", "b", "c") == Seq("a", "b") ++ Seq("c"))- the problem with this one is that it seems that instantiating a temporary sequence (- Seq("c")) just for the sake of the operation is rendundant and will result in overhead
- assert(Seq("a", "b", "c") == List("a", "b") ::: "c" :: Nil)- this one restricts the type of input collection to be a- List, so- Seq("a", "b") ::: "c" :: Nilwon't work. Also it seems that instantiating a- Nilmay aswell result in overhead
My questions are:
- Is there any other way of performing this operation?
- Which one is better?
- Isn't Seq("a", "b") ::: Nilnot being allowed a flaw of Scala's developers?
 
     
    