如果我有一个如下的案例类:
case class Student(name: String, activities: Seq[String], grade: String)
我有一个这样的列表:
val students = List(
Student("John",List("soccer","Video Games"),"9th"),
Student("Jane",List("sword fighting","debate"),"10th")
)
如何将整个内容转换为如下所示的字符串:
johnsoccervideogames9thjaneswordfightingdebate10th
我想把这个字符串作为MD5的一部分。
答案 0 :(得分:1)
这似乎可以满足您的期望。
students.map( student => student.name + student.activities.mkString + student.grade).mkString.toLowerCase.replaceAll("\\s", "")