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

sunlan pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 79c54de  Update 3.0 release note to add the sample code for Java-style 
non-static inner class instantiation.
79c54de is described below

commit 79c54dedf280e5edd262541d4c025c5b364d9c54
Author: Daniel Sun <sun...@apache.org>
AuthorDate: Sun Jan 6 01:21:20 2019 +0800

    Update 3.0 release note to add the sample code for Java-style non-static 
inner class instantiation.
---
 site/src/site/releasenotes/groovy-3.0.adoc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/site/src/site/releasenotes/groovy-3.0.adoc 
b/site/src/site/releasenotes/groovy-3.0.adoc
index c0a663d..8c11ae6 100644
--- a/site/src/site/releasenotes/groovy-3.0.adoc
+++ b/site/src/site/releasenotes/groovy-3.0.adoc
@@ -413,6 +413,25 @@ block (e.g. an if-then-else statement or another anonymous 
code block). Anywhere
 you might need to terminate the previous statement with a semicolon. In which 
case, see the
 note above about refactoring your code! :-)
 
+===  Java-style non-static inner class instantiation
+
+Java syntax for non-static inner class instantiation is now supported.
+
+[source,groovy]
+--------------------------------------
+public class Computer {
+    public class Cpu {
+        int coreNumber
+
+        public Cpu(int coreNumber) {
+            this.coreNumber = coreNumber
+        }
+    }
+}
+
+assert 4 == new Computer().new Cpu(4).coreNumber
+--------------------------------------
+
 ===  Interface default methods
 
 Java 8 supports adding default implementations to interfaces. Groovy now 
supports this too:

Reply via email to