12

a and b are values of Iterator[String] type. I need c to include all the elements of a and b. Surprisingly I can't figure out how to achieve this. May you happen to know?

1 Answer 1

23

++ operator will do that work.
An example:

scala> val a = "abcd".combinations(2)
//a: Iterator[String] = non-empty iterator

scala> val b = "efg".combinations(2)
//b: Iterator[String] = non-empty iterator

scala> val c = a++b
//c: Iterator[String] = non-empty iterator

scala> c.toList
//res0: List[String] = List(ab, ac, ad, bc, bd, cd, ef, eg, fg)
Sign up to request clarification or add additional context in comments.

2 Comments

Well, it's not really an operator, but it's still good reference.
@SargeBorsch It's no more incorrect to call a Scala infix unary method an operator than it is for a Haskell infix function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.