有trait
像下面这样的
trait MyTrait
{
val country: String,
val state: String,
val commune: String = "nothing"
}
现正实施MyTrait
case class ImplementTrait(
country:String,
state: String,
//commune, how to provide commune's default value if commune is not provided while initialising ImplementTrait
) extends MyTrait
例如
ImplementTrait(country, state)
,应该可以工作,因为它将采用commune
默认值
ImplementTrait(country, state, commune)
,也应该有效,因为commune
价值现在存在
有什么建议吗?