Jestem trochę nowy w Scali. Oto mój kod.Ostrzeżenie Scala może nie być wyczerpujące.
Option(Session.get().getAttribute("player")) match {
case None => {
val player = new Player(user.getEmail, user.getNickname).createOrGet
Session.get().setAttribute("player", player)
}
}
otrzymuję następujące ostrzeżenie przy kompilacji
Warning:(35, 11) match may not be exhaustive.
It would fail on the following input: Some(_)
Option(Session.get().getAttribute("player")) match {
^
Jak mogę rozwiązać ten problem? Czy istnieje sposób na przepisanie kodu w celu uniknięcia ostrzeżenia? (Używam Scala w wersji 2.10.2)
Dzięki. Wykorzystam to co zasugerowałeś –
Dla stylu, chciałbym 'Session.get.getAttr ("foo") mecz {case null => case _ =>} '. Łatwiejszy do odczytania lub' Option (...) lubElse alt'. Lub 'Some (Session.get) filter (_.getAttr (" foo ")! = null) orElse (s => Some (s.setAttr (" ", x))) lub podobnie. –