乐趣区

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)
    }
退出移动版