Scala Double Colon的含义(在上下文中)

时间:2015-02-19 18:06:09

标签: scala

如何完成val的声明:

case class Employee(id: String, name: String)
case class Jobsite(title: String)

val list: ::[Employee :: JobSite] = // complete me

这是为了帮助理解如何迭代它,比如list.foreach{...}

编辑:我以不同的方式重申了同样的问题。

1 个答案:

答案 0 :(得分:2)

case class Employee(id: String, name: String)
case class Jobsite(title: String)
val list = (Employee("1", "Jake"), Jobsite("Facebook")) :: (Employee("1", "Ashton"), Jobsite("Google")) :: (Employee("1", "Kirk"), Jobsite("Typesafe")):: Nil
list.foreach(println)

似乎这就是你所要求的。