revember use the closure clone:
1 )
class Product { String imgUrl } def p = new Product(imgUrl: "test1") def p1 p1 = {p}.clone() p1.imgUrl="test2" println "--"+p1.imgUrl println p.imgUrl
2 )
class Product { String name String imgUrl } def p = new Product(name:"1", imgUrl: "test1") def p1 = new Product(name:"2", imgUrl: "test2") def result = [] result <<p result <<p1 def result2 = [] def test result.each{ test = {it}.clone() result2 << test } test.imgUrl ="KKKKKK" println "-------------------"+test.imgUrl //def result2 = {[*result]}.clone() result2.each { it.imgUrl = it.name+"KK" } result2.each { println "-----"+it.imgUrl println "-----"+it.name } result.each { println "*****"+it.imgUrl println "*name*"+it.name }