箭头->运算符在芭蕾舞女演员中做什么?

问题描述 投票:0回答:1

我是这种语言的新手,几个月后才刚开始使用它,并且有一个相对基本的问题。我在理解其中的箭头->运算符时有些困惑。在Learn Ballerina By Example下的示例中,基本Hello World Main用以下代码描述:

import ballerina/io;

public function main() {
    io:println("Hello, World!");
}

并且在Hello Word Service示例中,代码如下:

import ballerina/http;
import ballerina/log;

service hello on new http:Listener(9090) {

    resource function sayHello(http:Caller caller, http:Request req) {

        var result = caller->respond("Hello, World!");

        if (result is error) {
            log:printError("Error sending response", result);
        }
    }
}

我的问题在一行中的Hello Word Service程序中

var result = caller->respond("Hello, World!");

我来自C / Python / Java背景,箭头在每种语言中表示不同的含义。它在芭蕾舞女演员中到底有什么用?我试图查找语法文档,但未成功找到它。指向特定页面的任何链接也将有所帮助。

提前感谢。

syntax wso2 ballerina
1个回答
0
投票

Ballerina中的->运算符表示远程交互。根据语言规范:

远程方法调用动作从工作人员生命线到客户端对象生命线。

remote-method-call-action := expression -> method-name ( arg-list )

请参阅下面的语言规范的“远程交互”部分,以获取更多信息。

https://ballerina.io/spec/lang/2019R3/#section_7.9

© www.soinside.com 2019 - 2024. All rights reserved.