summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/GenTraversableOnce.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-29 23:58:45 +0000
committerPaul Phillips <paulp@improving.org>2011-07-29 23:58:45 +0000
commit67a63278a6c4e9347792219086f11a87d177eee7 (patch)
tree411bab57bbcd9f408ee4230420a7897de952f58b /src/library/scala/collection/GenTraversableOnce.scala
parentaf412cd72e6e35e7c76ee24e9fa65b73293f0082 (diff)
downloadscala-67a63278a6c4e9347792219086f11a87d177eee7.tar.gz
scala-67a63278a6c4e9347792219086f11a87d177eee7.tar.bz2
scala-67a63278a6c4e9347792219086f11a87d177eee7.zip
- Update Scaladoc for LinkedList and for some o...
- Update Scaladoc for LinkedList and for some of the functions/operators - that it inherits. Completed Scaladoc for append Added example - in GenSeqLike for apply. Added $collectExample to collect in - GenTraversableLike and supplied an actual example in LinkedList Contributed by Donald McLean.
Diffstat (limited to 'src/library/scala/collection/GenTraversableOnce.scala')
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index 5045d4b829..3e42e7812b 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -114,7 +114,16 @@ trait GenTraversableOnce[+A] {
*/
def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1
- /** A syntactic sugar for out of order folding. See `fold`. */
+ /** A syntactic sugar for out of order folding. See `fold`.
+ *
+ * Example:
+ * {{{
+ * scala> val a = LinkedList(1,2,3,4)
+ * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ *
+ * scala> val b = (a /:\ 5)(_+_)
+ * b: Int = 15
+ * }}}*/
def /:\[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 = fold(z)(op)
/** Applies a binary operator to a start value and all elements of this $coll,
@@ -122,6 +131,21 @@ trait GenTraversableOnce[+A] {
*
* Note: `/:` is alternate syntax for `foldLeft`; `z /: xs` is the same as
* `xs foldLeft z`.
+ *
+ * Examples:
+ *
+ * Note that the folding function used to compute b is equivalent to that used to compute c.
+ * {{{
+ * scala> val a = LinkedList(1,2,3,4)
+ * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ *
+ * scala> val b = (5 /: a)(_+_)
+ * b: Int = 15
+ *
+ * scala> val c = (5 /: a)((x,y) => x + y)
+ * c: Int = 15
+ * }}}
+
* $willNotTerminateInf
* $orderDependentFold
*
@@ -145,6 +169,21 @@ trait GenTraversableOnce[+A] {
* $willNotTerminateInf
* $orderDependentFold
*
+ * Examples:
+ *
+ * Note that the folding function used to compute b is equivalent to that used to compute c.
+ * {{{
+ * scala> val a = LinkedList(1,2,3,4)
+ * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
+ *
+ * scala> val b = (a :\ 5)(_+_)
+ * b: Int = 15
+ *
+ * scala> val c = (a :\ 5)((x,y) => x + y)
+ * c: Int = 15
+ *
+ * }}}
+ *
* @param z the start value
* @param op the binary operator
* @tparam B the result type of the binary operator.