我有以下隐式转换java.util.Enumerations
implicit def enumerationIterator[A](e : Enumeration[A]) : Iterator[A] = {
new Iterator[A] {
def hasNext = e.hasMoreElements
def next = e.nextElement
def remove = throw new UnsupportedOperationException()
}
}
不幸的是,它不起作用,ZipFile.entries
因为它返回一个Enumeration<? extends ZipEntry>
(参见相关问题)并且 Scalac 一直告诉我
type mismatch; found : java.util.Iterator[?0]
where type ?0 <: java.util.zip.ZipEntry
required: Iterator[?]
我不知道如何使对话以某种方式进行。喜欢
List.fromIterator(new ZipFile(z).entries))