Skip to content

Instantly share code, notes, and snippets.

@int128
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save int128/10652217 to your computer and use it in GitHub Desktop.
Save int128/10652217 to your computer and use it in GitHub Desktop.
could not initialize immutable in immutable by map
@groovy.transform.Immutable
class A {
int x
}
@groovy.transform.Immutable
class B {
int y
@Delegate
A a = new A([:])
}
println new B(x: 200) // -> B(0, A(0))
println new B(y: 100) // -> B(100, A(0))
println new B(y: 100, x: 200) // -> B(100, A(0))
@groovy.transform.TupleConstructor
@groovy.transform.ToString
class A {
int x
}
@groovy.transform.TupleConstructor
@groovy.transform.ToString
class B {
int y
@Delegate
A a = new A()
}
println new B(x: 200) // -> B(0, A(200))
println new B(y: 100) // -> B(100, A(0))
println new B(y: 100, x: 200) // -> B(100, A(200))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment