summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-05-14 15:02:07 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-05-14 15:04:17 +0200
commitd7aec58bf3dfbe57c29ad29e7035a6a351620423 (patch)
treed76f15d305b9c3a5c57cf1d762639bce6ac55fed
parentc763d8413b8e1ef5129378952b2327e8a7c2de7d (diff)
downloadscala-d7aec58bf3dfbe57c29ad29e7035a6a351620423.tar.gz
scala-d7aec58bf3dfbe57c29ad29e7035a6a351620423.tar.bz2
scala-d7aec58bf3dfbe57c29ad29e7035a6a351620423.zip
SI-8587 Explicitly document forall/exists for empty collections
This behaviour isn't always intuitive for newcomers. Also changes inadvertant doc comment to an impl. comment.
-rw-r--r--src/library/scala/collection/TraversableLike.scala8
-rw-r--r--src/library/scala/collection/TraversableOnce.scala7
2 files changed, 7 insertions, 8 deletions
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index b60ea86ab0..d3a7db6968 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -345,8 +345,8 @@ trait TraversableLike[+A, +Repr] extends Any
* $mayNotTerminateInf
*
* @param p the predicate used to test elements.
- * @return `true` if the given predicate `p` holds for all elements
- * of this $coll, otherwise `false`.
+ * @return `true` if this $coll is empty, otherwise `true` if the given predicate `p`
+ * holds for all elements of this $coll, otherwise `false`.
*/
def forall(p: A => Boolean): Boolean = {
var result = true
@@ -362,8 +362,8 @@ trait TraversableLike[+A, +Repr] extends Any
* $mayNotTerminateInf
*
* @param p the predicate used to test elements.
- * @return `true` if the given predicate `p` holds for some of the
- * elements of this $coll, otherwise `false`.
+ * @return `false` if this $coll is empty, otherwise `true` if the given predicate `p`
+ * holds for some of the elements of this $coll, otherwise `false`
*/
def exists(p: A => Boolean): Boolean = {
var result = false
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index 072fd3da44..a8c4e047ab 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -85,10 +85,9 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
*/
def seq: TraversableOnce[A]
- /** Presently these are abstract because the Traversable versions use
- * breakable/break, and I wasn't sure enough of how that's supposed to
- * function to consolidate them with the Iterator versions.
- */
+ // Presently these are abstract because the Traversable versions use
+ // breakable/break, and I wasn't sure enough of how that's supposed to
+ // function to consolidate them with the Iterator versions.
def forall(p: A => Boolean): Boolean
def exists(p: A => Boolean): Boolean
def find(p: A => Boolean): Option[A]