Class 在scala中传递给另一个类时,对象的数据类型是什么?或者如何将对象类型作为参数传递给另一个类?
在下面的代码中,我想将profileobj传递给UserActor类,但是我应该为此指定什么类型,正如您所看到的,现在我将该类型设置为Any,但这不起作用Class 在scala中传递给另一个类时,对象的数据类型是什么?或者如何将对象类型作为参数传递给另一个类?,class,scala,object,actor,Class,Scala,Object,Actor,在下面的代码中,我想将profileobj传递给UserActor类,但是我应该为此指定什么类型,正如您所看到的,现在我将该类型设置为Any,但这不起作用 case class Profile(i: Int, j: Double) object Local { def main(args: Array[String]){ profileobj = new Profile(10, 20) var k = 30 ; } } val user
case class Profile(i: Int, j: Double)
object Local {
def main(args: Array[String]){
profileobj = new Profile(10, 20)
var k = 30 ;
}
}
val userActor = system.actorOf(Props(new UserActor(profileobj, k)), name = username)
class UserActor(profileobj: Any, k: Int) extends Actor {
var a: Int = profileobj1.i
}
我得到的错误是
value i is not a member of Any
var a: Int = profileobj1.i
如果不是这样,是否有其他方法将此对象传递给UserActor类?它是
本地的。type
-对象的名称,后跟type关键字
你可以在我的简编中阅读更多关于这方面的内容。它属于
Profile
,不是吗?还是有更微妙的问题?