I have an API (from third party java library) that looks like:
public List<?> getByXPath(String xpathExpr)
defined on a class called DomNode
I try this in scala function:
1: def removeChild(node: DomNode, xpath: String) {
2: val lst: List[?] = node.getByXPath(xpath)
3: val child: DomNode = lst(0)
4: child.getParentNode().removeChild(child)
}
but it does not compile in scala. I get error in line 2.
As per the answers I modified it and now it is:
1: def removeChild(node: DomNode, xpath: String) {
2: val lst = node.getByXPath(xpath)
3: val child = lst(0).asInstanceOf[DomNode]
4: child.getParentNode().removeChild(child)
}
Now I get error on line 3: lst of type java.util.List[?0] does not take parameters
I also tried val lst: List[_] = node.getByXPath(xpath) but this gives me error right on this same line:
type mismatch;
found : java.util.List[?0] where type ?0
required: scala.List[_]
So I am still stuck.
Re your error on line 3: remember that it is a Java list, not a Scala list, so try