【发布时间】:2017-09-12 20:38:03
【问题描述】:
我在 github 上有一个由 codacy 分析的项目。分析建议对以下代码行“避免使用null”:
def doSomethingWithPath(path:Path) = {
require(path != null, "Path should not be null") //<-to avoid
...
}
修复它的最简单的 scala 惯用方法是什么?
【问题讨论】:
-
考虑接受其中一个答案,或评论您认为它们不是解决方案的原因。这样,最终提出您问题的其他用户将获得有关如何解决相同问题的更多信息
标签: scala idioms preconditions codacy