Recursive value xxx needs type in Scala

前端 未结 2 1415
暖寄归人
暖寄归人 2021-02-18 22:21

I am confused about why Scala is complaining about this code. I have two classes which depend on each other. When I try to create a new instance of A without a type

2条回答
  •  滥情空心
    2021-02-18 22:56

    You can specify the type of y specifically and it will compile:

     val y : A = new A(new B(y))
    

提交回复
热议问题