summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@epfl.ch>2014-07-02 14:45:09 +0200
committerVlad Ureche <vlad.ureche@epfl.ch>2014-07-02 14:45:09 +0200
commit17bdf8bdf7ddd527bc21e9de9edea31c7e126f5a (patch)
treeeb5e85abaaaee2abeef77c50156b9c88930b0e5e
parent55b408fabf0624f8beaea8565d30d21e1f92b2aa (diff)
parent6c698089aeb55e649a65dd7ae1bce2b4514ee865 (diff)
downloadscala-17bdf8bdf7ddd527bc21e9de9edea31c7e126f5a.tar.gz
scala-17bdf8bdf7ddd527bc21e9de9edea31c7e126f5a.tar.bz2
scala-17bdf8bdf7ddd527bc21e9de9edea31c7e126f5a.zip
Merge pull request #3857 from jxcoder/issue-3856
[scaladoc] Added example to Option.collect method.
-rw-r--r--src/library/scala/Option.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index 905e925f57..5a1c832fae 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -251,6 +251,17 @@ sealed abstract class Option[+A] extends Product with Serializable {
* nonempty '''and''' `pf` is defined for that value.
* Returns $none otherwise.
*
+ * @example {{{
+ * // Returns Some(HTTP) because the partial function covers the case.
+ * Some("http").collect({case "http" => "HTTP"})
+ *
+ * // Returns None because the partial function doesn't cover the case.
+ * Some("ftp").collect({case "http" => "HTTP"})
+ *
+ * // Returns None because None is passed to the collect method.
+ * None.collect({case value => value})
+ * }}}
+ *
* @param pf the partial function.
* @return the result of applying `pf` to this $option's
* value (if possible), or $none.