Hi
I hope this question hasn't been answered yet somewhere else. Didn't find an answer here.
In my localisation system I've got a class named 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
}
//DO SOME OTHER THINGS
}
and an object named LanguageCentral
object LanguageCentral {
private var lang:Option[Language] = None
//SOME OTHER PRIVATE MEMBERS
def language = lang
def language_=(l:Option[Language]) = l match {
case None => {}
case Some(l) => setLanguage(l)
}
def setLanguage(l:Language) {
lang = Some(l)
//DO SOME OTHER THINGS
}
//DO LOTS OF OTHER THINGS
}
I haven't written any code that's using this framework yet but trying it in an interactive session revealed a type error I don't really 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 have a clue what's wrong. But from my experience with Haskell I guess that the solution is only a minor change away.;)
Could somebody help me? Thx.
P.S.: using Scala 2.8.0.final