Search code examples
javaselenium-webdriverxtendkrypton

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


I'm having an error when splitting data extract from excel. when I'm on a.java it works. But now I'm converting my scripts to Java Xtend and now I am having the following error.

enter image description here

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];'
}

Solution

  • Must admit, I don't know xtend, but from the docs it says :

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

    When a method call’s last parameter is a lambda it can be passed right after the parameter list. For instance if you want to sort some strings by their length, you could write :

    Collections::sort(someStrings) [ a, b | 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).

    Since it appears xtend automatically converts Arrays to Lists (page 15), try replacing the [0] with get(0), so :

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