Scala 是如何“填充”的? 缺少案例类的参数?

发布于 2024-07-25 07:00:46 字数 384 浏览 11 评论 0原文

当我调用时:

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 linked 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

死开点丶别碍眼 2024-08-01 07:00:46

您发送的是单例对象Exit。 在 Scala API 中,只需向下滚动浏览类,然后查找对象。

object Exit 
extends (AbstractActor, AnyRef) => Exit

现在,我还没有看到你的代码,所以我不知道你是如何使用它的。 但请注意,此对象 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.

object Exit 
extends (AbstractActor, AnyRef) => Exit

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文