Groovy web console

subscribe to the feed Subscribe
to this
site
enum_from (via #groovywebconsole)
tweet this snippet Tweet
this
script

enum_from

Published 6 months ago by Gabriel Bianchi
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
enum A{
    B('b'),
    C('c')

    final String a

    public A(String _a) {
        a = _a
    }

    public static A from(String _a) {
        values().find {it.a == _a}
    }
}

println A.from('b')
println A.from('z')