我有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>
(见related question)和Scalac不断告诉我
type mismatch; found : java.util.Iterator[?0]
where type ?0 <: java.util.zip.ZipEntry
required: Iterator[?]
我无法弄清楚如何使对话在某些方面起作用。像
List.fromIterator(new ZipFile(z).entries))
啊一个新手错误;-)谢谢。 – 2009-06-30 07:46:09