scala学习:枚举

Scala学习:枚举类型

枚举

 object Color extends Enumeration {
      val GREEN, RED, YELLOW = Value
    }

    for (color <- Color.values) {
      println(color)
    }

自定义Value

object Direction extends Enumeration{
      val NORTH = Value("N")
      val EAST = Value("E")
      val SOUTH = Value("S")
      val WEST = Value("W")
    }

    for (d <- Direction.values){
      println(d)
    }

你可能感兴趣的:(scala)