Groovy web console

subscribe to the feed Subscribe
to this
site

Get Custom Properties

Published 1 month ago by KK
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Foo {
    def bar = 42
    def baz = 1337
    
    def getBar() {
        return Math.PI
    }
}

def f = new Foo()
f.getProperties().each {
    println "$it.key -> $it.value"
}

/* baz -> 1337
 * class -> class Foo
 * bar -> 3.141592653589793
 */