Groovy web console

subscribe to the feed Subscribe
to this
site

Demo Enum

Published 2 months ago by OFA
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
enum EnumTest {	
CAS1('01'), CAS2('02')

	private final String value

EnumTest (String value) {
  this.value = value
	}

	def value() {
  value
	}
}

def test1 = EnumTest.CAS1
println "${test1} : ${test1.value}"
println "test1 == EnumTest.CAS1 : ${test1 == EnumTest.CAS1}"

def test2 = EnumTest.CAS2
println "${test2} : ${test2.value}"
println "test2 != EnumTest.CAS1 : ${test2 != EnumTest.CAS1}"