最佳答案
假设我有一个 session.get(str: String): String
方法,但是您不知道它是返回一个字符串还是一个 null,因为它来自 Java。
Is there an easier way to treat this in Scala instead of session.get("foo") == null
? Maybe some magic apply like ToOption(session.get("foo"))
and then I can treat it in Scala way like
ToOption(session.get("foo")) match {
case Some(_) =>;
case None =>;
}