ForEach constructor
ForEach()
Implementation
ForEach()
: super(
methodName: "forEach",
targetType: .list,
arity: 1,
function: (target, vm, arguments) async {
if (arguments[0] is! ObjClosure) {
throw RuntimeError("forEach() requires a function as an argument");
}
for (var element in target) {
await invokeScriptClosure(vm, arguments[0], [element]);
}
return target.length;
},
);