syntax - Ballerina 中箭头 -> 运算符的作用是什么?

标签 syntax wso2 ballerina

我是这种语言的新手,几个月后才重新开始使用它,并且有一个相对基本的问题。我对箭头的理解有些困惑 ->运营商在其中。在 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 背景,箭头在这些语言中的每一种都意味着不同的东西。它在芭蕾舞女 Actor 中有什么特别的作用?我试图寻找语法文档,但没有找到。任何指向特定页面的链接也会有所帮助。

提前致谢。

最佳答案

-> Ballerina 中的操作符代表远程交互。根据语言规范:

A remote-method-call-action is depicted as a horizontal arrow from the worker lifeline to the client object lifeline.

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



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

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

关于syntax - Ballerina 中箭头 -> 运算符的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59460463/

相关文章:

javascript - Vim 中的 Syntastic 声明函数可能无法返回

java - 这行代码有语法错误吗?

wso2 - 身份验证框架 WSO2 IS 中的异常

ballerina - 运行时错误芭蕾舞女 Actor

Ballerina 中的正则表达式模式搜索

kubernetes - 芭蕾舞女 Actor “undefined package ”与Visual Code中的kubernetes

c++ - 点运算符和点运算符有什么意义?

python - 无论我在 if 语句下写什么,语法错误

WSO2 IS 5.1.0 - 使用 Soap 更新服务提供程序时出错

wso2 上午 1.10.0 API 商店 : "Error occurred while executing the action generateApplicationKey" with "Invalid credentials provided."