Hey fellas,
What is a neat way to hold pairs of strings which are not necessarily key-values (might have duplicate keys), for a small collection? List[List[String]] works obviously but looks dirty.
Cheers
Parsa
Hey fellas,
What is a neat way to hold pairs of strings which are not necessarily key-values (might have duplicate keys), for a small collection? List[List[String]] works obviously but looks dirty.
Cheers
Parsa
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))
Tuples are the ideal data structure to represent pairs.
So use a list of (String, String)
tuples.