Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于小型集合,保存不一定是键值(可能具有重复键)的字符串对的一种简洁方法是什么?List[List[String]] 显然有效,但看起来很脏。
干杯 帕萨
List[(String,String)]是标准溶液:
List[(String,String)]
scala> List(("foo","bar"), ("foo","baz")) res1: List[(java.lang.String, java.lang.String)] = List((foo,bar), (foo,baz))
元组是表示对的理想数据结构。
所以使用(String, String)元组列表。
(String, String)