Groovy web console

subscribe to the feed Subscribe
to this
site
No 'new' creating instances (via #groovywebconsole)
tweet this snippet Tweet
this
script

No 'new' creating instances

Published 2 years ago by Alex Tkachman
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
Class.metaClass.static.getAt = { args -> delegate.newInstance(*args) }

class Pair { 
    int a, b 
    
    Pair(int a, int b) { 
        this.a = a 
        this.b = b 
    }

    String toString () { "$a, $b" }
}

Pair[0,10]