Scala: a good way to keep a couple of lines

What is a neat way to hold pairs of rows that are not necessarily key (may have duplicate keys) for a small collection? The [List [String]] list works explicitly, but looks dirty.

Greetings
Pars

+6
set scala scala-collections map
source share
2 answers

Tuples are an ideal data structure for representing pairs.

So use a list of tuples (String, String) .

+11
source share

List[(String,String)] is the standard solution:

 scala> List(("foo","bar"), ("foo","baz")) res1: List[(java.lang.String, java.lang.String)] = List((foo,bar), (foo,baz)) 
+14
source share

All Articles