我有以下针对
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[?]
我无法弄清楚如何在类似于sth的对话中使其工作。
List.fromIterator(new ZipFile(z).entries))