简体   繁体   English

错误:类型不匹配:无法使用Java Xtend从(Object)=> int转换为int

[英]Error: Type mismatch: cannot convert from (Object)=>int to int using Java Xtend

I'm having an error when splitting data extract from excel. 从Excel拆分数据提取时出现错误。 when I'm on a.java it works. 当我在a.java上工作时。 But now I'm converting my scripts to Java Xtend and now I am having the following error. 但是现在我将脚本转换为Java Xtend,现在遇到以下错误。

在此处输入图片说明

Here is the code 这是代码

var dashboards = M3ASmokeTest.ReadExcelFile();
var countdsh = 0;
var countdom = 0;
var countrep = 0;
Thread.sleep(20000);
for(String groupedDomain: dashboards)
{
    var domain = dashboards.get(countdom).split(";")[0];
    var dboards = dashboards.get(countdsh).split(";")[1];
    var reports = dashboards.get(countdsh).split(";")[2];'
}

Must admit, I don't know xtend, but from the docs it says : 必须承认,我不了解xtend,但是从文档中可以看到:

https://www.eclipse.org/xtend/documentation/2.3.0/Documentation.pdf page 39 https://www.eclipse.org/xtend/documentation/2.3.0/Documentation.pdf第39页

When a method call's last parameter is a lambda it can be passed right after the parameter list. 当方法调用的最后一个参数是lambda时,可以在参数列表之后立即传递它。 For instance if you want to sort some strings by their length, you could write : 例如,如果您想按长度对某些字符串进行排序,则可以编写:

Collections::sort(someStrings) [ a, b | Collections :: sort(someStrings)[a,b | a.length - b.length ] a.length-b.length]

So the square brackets denote lambda expressions, which is what you're getting (so I'm guessing a bug in xtend that it's incorrectly trying to apply that in your case). 因此,方括号表示的是lambda表达式,这就是您所得到的(因此,我猜测xtend中的一个错误是它错误地尝试在您的情况下应用该表达式)。

Since it appears xtend automatically converts Arrays to Lists (page 15), try replacing the [0] with get(0), so : 由于xtend似乎自动将数组转换为列表(第15页),请尝试用get(0)替换[0],因此:

var domain = dashboards.get(countdom).split(";").get(0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM