小编Nuv*_*ana的帖子

如何正确比较 Ballerina 中两个变量的类型并确保它们具有相同的类型?

我正在与 Ballerina 合作并尝试比较两个变量的类型以确保它们具有相同的类型。代码片段如下所示:

typedesc type1 = typeof input1;
typedesc type2 = typeof input2;  
if type1 == type2 {
   //...
}
Run Code Online (Sandbox Code Playgroud)

类型检查运算==符无法按预期工作。我可以使用type1.toString() == type2.toString(),但它不适用于联合类型和不可变记录。

type-equivalence ballerina

4
推荐指数
1
解决办法
63
查看次数

标签 统计

ballerina ×1

type-equivalence ×1