【发布时间】:2012-04-21 20:09:49
【问题描述】:
我有一个包含多个产品的 Brand 类
在产品类中,我想引用品牌,如下所示:
case class Brand(val name:String, val products: List[Product])
case class Product(val name: String, val brand: Brand)
如何填充这些类???
我的意思是,除非我有品牌,否则我无法创造产品
除非我有产品列表,否则我无法创建品牌(因为 Brand.products 是 val)
模拟这种关系的最佳方法是什么?
【问题讨论】:
标签: oop scala relationship