/**
 * Created by Jxy on 2019/1/3 15:42
 * groovy对枚举的支持
 */

enum CoffeeSize{
    SHORT,SMALL,BIG,MUG
}
def orderCoffee(size){
    println "coffee is $size"
    switch (size){
        case [CoffeeSize.SHORT,CoffeeSize.SMALL]:
            println "your are health conscious"
            break
        case [CoffeeSize.BIG,CoffeeSize.MUG]:
            println "your are big health conscious"
            break
    }
}
orderCoffee(CoffeeSize.MUG)
for(size in CoffeeSize.values()){
    print "$size ,"
}

 

相关文章:

  • 2021-09-21
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2021-05-21
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2021-10-10
  • 2021-08-30
  • 2022-12-23
  • 2021-06-29
  • 2021-07-19
相关资源
相似解决方案