我找到了一个如何enum
在 Scala 中实现的示例,这就是我所拥有的:
package org.myproject
object MyEnum extends Enumeration {
type MyEnum = Value
val val1, val2, val3 = Value
}
但尽管如此,我有一个错误type MyEnum is not a member of package org.myproject
:
package org.myproject.subnamespace
import org.myproject.MyEnum
abstract class MyClass {
def myEnum123: MyEnum
}
请注意,它们位于略有不同的包中。
更新:有2个错误,实际上,这取决于我如何定义def
:
package org.myproject.subnamespace
import org.myproject.MyEnum
abstract class MyClass {
def myEnum123: MyEnum // not found: type MyEnum
def myEnum123: org.myproject.MyEnum // type MyEnum is not a member of package org.myproject
}
怎么了?