I would question why you repeat the information, saying which products belong to that brand both in the list and in each product.
However, you can do this:
class Brand(val name: String, ps: => List[Product]) { lazy val products = ps override def toString = "Brand("+name+", "+products+")" } class Product(val name: String, b: => Brand) { lazy val brand = b override def toString = "Product("+name+", "+brand.name+")" } lazy val p1: Product = new Product("fish", birdseye) lazy val p2: Product = new Product("peas", birdseye) lazy val birdseye = new Brand("BirdsEye", List(p1, p2)) println(birdseye)
The by-name parameter is apparently not allowed for case classes.
See also this similar question: Running immutable paired objects
source share