You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/08/27 02:51:41 UTC

[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 <pa...@asert.com.au>
Authored: Thu Aug 27 10:43:09 2015 +1000
Committer: paulk <pa...@asert.com.au>
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;
  * <p>
  * Groovy allows instances of Closures to be called in a
  * short form. For example:
- * <pre>
+ * <pre class="groovyTestCase">
  * 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
- * <pre>
+ * <pre class="groovyTestCase">
  * def a = 1
  * def c = {a}
  * assert c.call() == 1
@@ -561,7 +561,7 @@ public abstract class Closure<V> 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:
-     * <pre>
+     * <pre class="groovyTestCase">
      * def divide = { a, b -> a / b }
      * def halver = divide.rcurry(2)
      * assert halver(8) == 4
@@ -635,12 +635,12 @@ public abstract class Closure<V> extends GroovyObjectSupport implements Cloneabl
      * Support for Closure forward composition.
      * <p>
      * Typical usage:
-     * <pre>
-     * def twice = { a -> a * 2 }
+     * <pre class="groovyTestCase">
+     * 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
      * </pre>
      *
      * @param other the Closure to compose with the current Closure
@@ -654,12 +654,12 @@ public abstract class Closure<V> extends GroovyObjectSupport implements Cloneabl
      * Support for Closure reverse composition.
      * <p>
      * Typical usage:
-     * <pre>
-     * def twice = { a -> a * 2 }
+     * <pre class="groovyTestCase">
+     * 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
      * </pre>
      *
      * @param other the Closure to compose with the current Closure
@@ -673,10 +673,10 @@ public abstract class Closure<V> extends GroovyObjectSupport implements Cloneabl
      * Alias for calling a Closure for non-closure arguments.
      * <p>
      * Typical usage:
-     * <pre>
-     * def twice = { a -> a * 2 }
-     * def thrice = { a -> a * 3 }
-     * assert thrice << twice << 3 == 18
+     * <pre class="groovyTestCase">
+     * def times2 = { a -> a * 2 }
+     * def add3 = { a -> a * 3 }
+     * assert add3 << times2 << 3 == 9
      * </pre>
      *
      * @param arg the argument to call the closure with


[2/2] incubator-groovy git commit: GROOVY-7556: Use better example for Closure composition

Posted by pa...@apache.org.
GROOVY-7556: Use better example for Closure composition


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/cdbdcd35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/cdbdcd35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/cdbdcd35

Branch: refs/heads/GROOVY_2_4_X
Commit: cdbdcd350d2cd31d54fa520f1510a25aa512b6a9
Parents: 3b7ad12
Author: Matt Whipple <ma...@mattwhipple.com>
Authored: Wed Aug 26 07:00:48 2015 -0400
Committer: paulk <pa...@asert.com.au>
Committed: Thu Aug 27 10:51:23 2015 +1000

----------------------------------------------------------------------
 src/main/groovy/lang/Closure.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/cdbdcd35/src/main/groovy/lang/Closure.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/Closure.java b/src/main/groovy/lang/Closure.java
index 081fa02..c8ba7a0 100644
--- a/src/main/groovy/lang/Closure.java
+++ b/src/main/groovy/lang/Closure.java
@@ -637,10 +637,10 @@ public abstract class Closure<V> extends GroovyObjectSupport implements Cloneabl
      * Typical usage:
      * <pre>
      * def twice = { a -> a * 2 }
-     * def thrice = { a -> a * 3 }
-     * def times6 = twice >> thrice
-     * // equivalent: times6 = { a -> thrice(twice(a)) }
-     * assert times6(3) == 18
+     * def add3 = { a -> a + 3 }
+     * def transform = twice >> add3
+     * // equivalent: transform = { a -> add3(twice(a)) }
+     * assert transform(3) == 9
      * </pre>
      *
      * @param other the Closure to compose with the current Closure
@@ -656,10 +656,10 @@ public abstract class Closure<V> extends GroovyObjectSupport implements Cloneabl
      * Typical usage:
      * <pre>
      * def twice = { a -> a * 2 }
-     * def thrice = { a -> a * 3 }
-     * def times6 = thrice << twice
-     * // equivalent: times6 = { a -> thrice(twice(a)) }
-     * assert times6(3) == 18
+     * def add3 = { a -> a + 3 }
+     * def transform = twice << add3
+     * // equivalent: transform = { a -> twice(add3(a)) }
+     * assert transform(3) == 12
      * </pre>
      *
      * @param other the Closure to compose with the current Closure