You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/04/07 13:31:05 UTC
[22/50] [abbrv] groovy git commit: DefaultGroovyMethods#any: add
examples to javadoc
DefaultGroovyMethods#any: add examples to javadoc
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d05cdcc6
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d05cdcc6
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d05cdcc6
Branch: refs/heads/parrot
Commit: d05cdcc67266f3c8aa1be1c5dc8cd02fbd6e01e7
Parents: e8863f4
Author: pascalschumacher <pa...@gmx.net>
Authored: Sat Mar 18 10:39:44 2017 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sat Mar 18 10:39:44 2017 +0100
----------------------------------------------------------------------
.../groovy/runtime/DefaultGroovyMethods.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/d05cdcc6/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 96c99d9..219226f 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -2432,6 +2432,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
/**
* Iterates over the contents of an object or collection, and checks whether a
* predicate is valid for at least one element.
+ * <pre class="groovyTestCase">
+ * assert [1, 2, 3].any { it == 2 }
+ * assert ![1, 2, 3].any { it > 3 }
+ * </pre>
*
* @param self the object over which we iterate
* @param closure the closure predicate used for matching
@@ -2449,6 +2453,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
/**
* Iterates over the contents of an iterator, and checks whether a
* predicate is valid for at least one element.
+ * <pre class="groovyTestCase">
+ * assert [1, 2, 3].iterator().any { it == 2 }
+ * assert ![1, 2, 3].iterator().any { it > 3 }
+ * </pre>
*
* @param self the iterator over which we iterate
* @param closure the closure predicate used for matching
@@ -2466,6 +2474,10 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
/**
* Iterates over the contents of an iterable, and checks whether a
* predicate is valid for at least one element.
+ * <pre class="groovyTestCase">
+ * assert [1, 2, 3].any { it == 2 }
+ * assert ![1, 2, 3].any { it > 3 }
+ * </pre>
*
* @param self the iterable over which we iterate
* @param closure the closure predicate used for matching
@@ -2510,6 +2522,11 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* Iterates over the elements of a collection, and checks whether at least
* one element is true according to the Groovy Truth.
* Equivalent to self.any({element -> element})
+ * <pre class="groovyTestCase">
+ * assert [false, true].any()
+ * assert [0, 1].any()
+ * assert ![0, 0].any()
+ * </pre>
*
* @param self the object over which we iterate
* @return true if any item in the collection matches the closure predicate