相关疑难解决方法(0)

如何在Scala中编写此验证逻辑?

假设我想在Scala中编写以下逻辑

val xdir = System.getProperty("XDir")
if (xdir == null)
   error("No XDir") // log the error and exit

val ydir = System.getProperty("YDir") 
if (ydir == null)
   error("No YDir")

if (!new File(xdir).isDirectory)
   error("XDir is not a directory")

if (!new File(ydir).isDirectory)
   error("YDir is not a directory")

if (!new File(xdir).exists)
   error("XDir does not exis")

if (!new File(ydir).exists)
   error("YDir does not exist")
...
(and so on)

在Scala中编写此验证链的最佳方法是什么?

scala

6
推荐指数
1
解决办法
562
查看次数

标签 统计

scala ×1