Return-Path: X-Original-To: apmail-groovy-commits-archive@minotaur.apache.org Delivered-To: apmail-groovy-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3ECA918277 for ; Thu, 27 Aug 2015 00:51:48 +0000 (UTC) Received: (qmail 14871 invoked by uid 500); 27 Aug 2015 00:51:48 -0000 Delivered-To: apmail-groovy-commits-archive@groovy.apache.org Received: (qmail 14836 invoked by uid 500); 27 Aug 2015 00:51:48 -0000 Mailing-List: contact commits-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.incubator.apache.org Delivered-To: mailing list commits@groovy.incubator.apache.org Received: (qmail 14827 invoked by uid 99); 27 Aug 2015 00:51:48 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Aug 2015 00:51:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B0593EE67A for ; Thu, 27 Aug 2015 00:51:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.355 X-Spam-Level: X-Spam-Status: No, score=0.355 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id jV3ZgxCmKpz4 for ; Thu, 27 Aug 2015 00:51:42 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 0227F2770F for ; Thu, 27 Aug 2015 00:51:41 +0000 (UTC) Received: (qmail 14790 invoked by uid 99); 27 Aug 2015 00:51:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Aug 2015 00:51:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0B6DAE7140; Thu, 27 Aug 2015 00:51:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulk@apache.org To: commits@groovy.incubator.apache.org Date: Thu, 27 Aug 2015 00:51:41 -0000 Message-Id: <9e4716dbc50c4d16b0d54432b9c03a20@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] incubator-groovy git commit: GROOVY-7556: Use better example for Closure composition (closes #102) Repository: incubator-groovy Updated Branches: refs/heads/GROOVY_2_4_X 3b7ad1234 -> 9b42a5f0a GROOVY-7556: Use better example for Closure composition (closes #102) Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/9b42a5f0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/9b42a5f0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/9b42a5f0 Branch: refs/heads/GROOVY_2_4_X Commit: 9b42a5f0a3eaa13ad2a5b13a6d50aaf8329d4c5b Parents: cdbdcd3 Author: paulk Authored: Thu Aug 27 10:43:09 2015 +1000 Committer: paulk Committed: Thu Aug 27 10:51:23 2015 +1000 ---------------------------------------------------------------------- src/main/groovy/lang/Closure.java | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/9b42a5f0/src/main/groovy/lang/Closure.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/lang/Closure.java b/src/main/groovy/lang/Closure.java index c8ba7a0..19fc960 100644 --- a/src/main/groovy/lang/Closure.java +++ b/src/main/groovy/lang/Closure.java @@ -36,7 +36,7 @@ import java.io.Writer; *

* Groovy allows instances of Closures to be called in a * short form. For example: - *

+ * 
  * def a = 1
  * def c = { a }
  * assert c() == 1
@@ -48,7 +48,7 @@ import java.io.Writer;
  * {@link #getParameterTypes()} will work too without any
  * additional code. If no doCall method is provided a
  * closure must be used in its long form like
- * 
+ * 
  * def a = 1
  * def c = {a}
  * assert c.call() == 1
@@ -561,7 +561,7 @@ public abstract class Closure extends GroovyObjectSupport implements Cloneabl
      * Support for Closure "right" currying.
      * Parameters are supplied on the right rather than left as per the normal curry() method.
      * Typical usage:
-     * 
+     * 
      * def divide = { a, b -> a / b }
      * def halver = divide.rcurry(2)
      * assert halver(8) == 4
@@ -635,12 +635,12 @@ public abstract class Closure extends GroovyObjectSupport implements Cloneabl
      * Support for Closure forward composition.
      * 

* Typical usage: - *

-     * def twice = { a -> a * 2 }
+     * 
+     * def times2 = { a -> a * 2 }
      * def add3 = { a -> a + 3 }
-     * def transform = twice >> add3
-     * // equivalent: transform = { a -> add3(twice(a)) }
-     * assert transform(3) == 9
+     * def timesThenAdd = times2 >> add3
+     * // equivalent: timesThenAdd = { a -> add3(times2(a)) }
+     * assert timesThenAdd(3) == 9
      * 
* * @param other the Closure to compose with the current Closure @@ -654,12 +654,12 @@ public abstract class Closure extends GroovyObjectSupport implements Cloneabl * Support for Closure reverse composition. *

* Typical usage: - *

-     * def twice = { a -> a * 2 }
+     * 
+     * def times2 = { a -> a * 2 }
      * def add3 = { a -> a + 3 }
-     * def transform = twice << add3
-     * // equivalent: transform = { a -> twice(add3(a)) }
-     * assert transform(3) == 12
+     * def addThenTimes = times2 << add3
+     * // equivalent: addThenTimes = { a -> times2(add3(a)) }
+     * assert addThenTimes(3) == 12
      * 
* * @param other the Closure to compose with the current Closure @@ -673,10 +673,10 @@ public abstract class Closure extends GroovyObjectSupport implements Cloneabl * Alias for calling a Closure for non-closure arguments. *

* Typical usage: - *

-     * def twice = { a -> a * 2 }
-     * def thrice = { a -> a * 3 }
-     * assert thrice << twice << 3 == 18
+     * 
+     * def times2 = { a -> a * 2 }
+     * def add3 = { a -> a * 3 }
+     * assert add3 << times2 << 3 == 9
      * 
* * @param arg the argument to call the closure with