Scala 是如何“填充”的? 缺少案例类的参数?
当我调用时:
actor_ ! Exit
这是如何转换为以下结构的:
case class Exit(from: AbstractActor, reason: AnyRef)
特别是,当我从已链接
到远程(服务器)的远程(客户端)参与者调用它时,情况如何? actor,服务器接收一个 Exit
实例,其中 from
属性是一个 actor:
'remotesender0@Node(10.10.7.90,8366)
基本上我想弄清楚如何获取此远程的句柄 -客户-演员对象!
When I call:
actor_ ! Exit
How is this being converted into a construction of:
case class Exit(from: AbstractActor, reason: AnyRef)
In particular, how is it that when I call this from a remote (client) actor which has been link
ed to a remote (server) actor, that the server receives an instance of Exit
where the from
property is an actor:
'remotesender0@Node(10.10.7.90,8366)
Basically I'd like to figure out how I can get a handle on this remote-client-actor object!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您发送的是单例对象
Exit
。 在 Scala API 中,只需向下滚动浏览类,然后查找对象。现在,我还没有看到你的代码,所以我不知道你是如何使用它的。 但请注意,此对象 Exit 是(实际上是扩展)一个函数,它接受两个参数并返回由它们形成的 Exit 案例类。 它还会在 case 类语句中放入一些内容。
或者,换句话说,Exit.apply(x,y)(正在应用的 Exit 函数)与 Exit(x,y)(Exit 类的构造函数)具有相同的结果。 但是,虽然您不能传递类,但可以传递对象。
What you are sending is the singleton object
Exit
. In the Scala API, just scroll down past the classes, and look up the objects.Now, I haven't seen your code, so I don't know how you are using it. Notice, though, that this object Exit is (actually, extends) a function, which takes two parameters and returns an Exit case class formed by them. It will also have some stuff put in it by the case class statement.
Or, in other words, Exit.apply(x,y) (the function Exit being applied) has the same result as Exit(x,y) (the constructor for class Exit). But while you can't pass a class, you can pass an object.