我需要創建可選字段的情況下。我類到refered Case Classes with optional fields in Scala有效的方式來創建可選字段
case class Student(firstName: String, lastName: Option[String] = None)
case class Student1(firstName: String,addd:String,lastName: Option[String] = None,surname:Option[String] = None)
並初始化它的方式案例類,有沒有其他辦法有效的方法除了使用
Some("Bar")
初始化它,因爲我有許多字段apporx爲15。Student("Foo") Student("Foo", None) // equal to the one above Student("Foo", Some("Bar"))
print(Student1("Foo","abc",None,Some("abc")))
,我想有一個 替代無如果我們在田地裏
println(Student("Foo").productIterator.mkString("\n"))
它打印
Foo
None
迭代210
我想刪除無
我認爲這取決於你的意思是什麼overloadin'efficient' – mfirry