How do I properly call exists for java.util.Enumeration? I cannot change the source, it's from HttpServletRequest.
This (unrelated) code works:
val a = List("One", "Two", "Three")
a exists (_ contains "T")
But why this code cannot be compiled:
import collection.JavaConversions.enumerationAsScalaIterator
enumerationAsScalaIterator(req.getHeaderNames[String])[String] exists (_ contains "T")
I'm using IntelliJ as my IDE. The above code doesn't show any error in the editor but will throw error when compiled:
error: ';' expected but '[' found. enumerationAsScalaIterator(req.getHeaderNames[String])[String] exists (_ contains "T")