【发布时间】:2020-02-11 15:52:08
【问题描述】:
case class Person(first: String, last: String, full: String = "blah")
val one = Person("Rachel","Green")
// one: Person = Person(Rachel,Green,blah)
val tuple1 = ("Ross","Geller")
// tuple1: (String, String) = (Ross,Geller)
Person tupled tuple1
// <console>:15: error: type mismatch; found : (String, String) required: (String, String, String
我想将 Tuple13 转换为具有默认值的案例类。
【问题讨论】:
-
遗憾的是,一个 函数 不能有像 methods 这样的默认值。
标签: scala tuples case-class