This is an automated email from the ASF dual-hosted git repository.

glaforge pushed a commit to branch with-to-tap-doc-fix
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/with-to-tap-doc-fix by this 
push:
     new dd04711291 Use the tap() method instead of with(), as tap() returns 
the object instead of returning the last expression of the closure like with 
with(). Without this change, variable p3 actually contained the int 1951
dd04711291 is described below

commit dd04711291319589630b6ba8f86f2baacc834265
Author: Guillaume Laforge <glafo...@gmail.com>
AuthorDate: Wed Sep 13 10:36:54 2023 +0200

    Use the tap() method instead of with(), as tap() returns the object instead 
of returning the last expression of the closure like with with().
    Without this change, variable p3 actually contained the int 1951
---
 src/spec/test/CodeGenerationASTTransformsTest.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spec/test/CodeGenerationASTTransformsTest.groovy 
b/src/spec/test/CodeGenerationASTTransformsTest.groovy
index 0d1345027b..096ff94102 100644
--- a/src/spec/test/CodeGenerationASTTransformsTest.groovy
+++ b/src/spec/test/CodeGenerationASTTransformsTest.groovy
@@ -1313,7 +1313,7 @@ assert "$p1.first $p1.last" == 'Johnny Depp'
 // end::builder_simple_usage[]
 // tag::builder_simple_alternatives[]
 def p2 = new Person(first: 'Keira', last: 'Knightley', born: 1985)
-def p3 = new Person().with {
+def p3 = new Person().tap {
     first = 'Geoffrey'
     last = 'Rush'
     born = 1951

Reply via email to