I hope this question has not yet been answered. Did not find the answer here.
In my localization system, I have a class called Language
class Language(val name:String, dict:HashMap[String, String]) { def apply(key: String):String = (dict get key) match { case None => "°unknown°" case Some(s) => s }
and an object named LanguageCentral
object LanguageCentral { private var lang:Option[Language] = None
I have not yet written the code that used this framework, but, having tried it in an interactive session, I found a type error that I really don't understand:
scala> val l = new LanguageCreator("Languages.csv").getLanguage("English") l: Option[Language] = Some( Language@7aeb46d ) scala> LanguageCentral.language=l <console>:23: error: type mismatch; found : Option[Language] required: Option[Language] LanguageCentral.language=l ^ scala> LanguageCentral setLanguage (l getOrElse null) <console>:24: error: type mismatch; found : Language required: Language LanguageCentral setLanguage (l getOrElse null) ^
I really don't understand what happened. But in my experience with Haskell, I assume that the solution is only a minor change.)
Can anyone help me? thanks.
PS: using Scala 2.8.0.final
source share