我的代码有问题吗,因为函数中的逻辑在 js 中运行良好?

Is there something wrong with my code as logic in function works fine in js?

* def a = ["a","b"]
* def b = ["1","2"]
* def fun =
"""
function(a,b){
var result={}
a.forEach(function(x,i){result[x]=b[i]});
return result;}
"""

* def final = fun(a,b)
* print final

现在我期待的是 { “一个”:“1”, “乙”:“2” } 但我得到的是{ “一个”:空, “b”:空 }?

空手道中的JS块有限制,就是这样。

改为这样做:

karate.forEach(a, function(x,i){result[x]=b[i]});