6
我試圖學習一些斯卡拉閱讀Programming Scala, by Dean Wampler。foreach和枚舉
我試圖複製有關Enumeration
object Breed extends Enumeration {
val doberman = Value("Doberman Pinscher")
val yorkie = Value("Yorkshire Terrier")
val scottie = Value("Scottish Terrier")
val dane = Value("Great Dane")
val portie = Value("Portuguese Water Dog")
}
for (breed <- Breed) println(breed.id + "\t" + breed)
但代碼片段,在最後一行代碼中,我得到這個錯誤:
value foreach is not a member of object Breed
我缺少的東西?我該如何解決?