Scala 解析参数

object ParamParser {


  def main(args: Array[String]): Unit = {

    val list = List("--table", "app.app_dm_online_log", "--memory", "4G")
    parse(list)
    println(tableName)
    println(memory)


  }

  var tableName: String = _
  var memory: String = _


  def parse(list: List[String]): Unit = list match {
    case "--table" :: value :: tail =>
      tableName = value;
      parse(tail)

    case "--memory" :: value :: tail =>
      memory = value
      parse(tail)

    case Nil =>

  }

}

  

posted @ 2019-06-13 18:16  bf378  阅读(894)  评论(0编辑  收藏  举报