Groovy web console

subscribe to the feed Subscribe
to this
site

hh

Published 2 weeks ago by hh with tags groovy
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
println GroovySystem.version
println this.getClass().getName()
List<String> b = ['man', 'lady']

def x = { List<String> p ->
    //delegate = this
    
    //c.delegate = builder
    resolveStrategy = Closure.TO_SELF 
    println delegate.getClass().getName()
    println p.hashCode();
    println b // this can be SEEN !!! Wo! Wo!
    //println this.b // b is not a property because this does not work
    List<String> inx = ['dog','cat']
    List<String> isHsame = ['man','lady']
    for (String l : inx) 
    { 
        p.add(l) 
    }
    //p = p + inx
    //p = p.plus(inx)
    println p.hashCode()
    println isHsame.hashCode()

}

def xmethod(List<String> p)
{
    List<String> inx = ['monkey','lion']
    /*for (String l : inx) 
    { 
      p.add(l) 
    }*/
    p = p + inx
    //println b // this obey's java 
    
}

x( b )
println b

xmethod( b )
println b

List<String> outside = ['building', 'house']
//b = b + outside
//b = b.plus(outside)
b.plus(outside)
println b; println b.hashCode()