diff options
author | Vlad Ureche <vlad.ureche@epfl.ch> | 2014-07-09 21:41:53 +0200 |
---|---|---|
committer | Vlad Ureche <vlad.ureche@epfl.ch> | 2014-07-09 21:41:53 +0200 |
commit | b1b0b5c58ece31b767de93ec49455b72b3b229b7 (patch) | |
tree | f8994688e5be604b9465573a1a63a91fe00c02a4 | |
parent | 47c62158b98d6faa74c7466dd30c28ad421ae8ff (diff) | |
parent | e3311073bbad6f6f0dfdd3ea09628d324b4b3614 (diff) | |
download | scala-b1b0b5c58ece31b767de93ec49455b72b3b229b7.tar.gz scala-b1b0b5c58ece31b767de93ec49455b72b3b229b7.tar.bz2 scala-b1b0b5c58ece31b767de93ec49455b72b3b229b7.zip |
Merge pull request #3864 from jxcoder/SI-8705
SI-8705 Added example to Option.contains method.
-rw-r--r-- | src/library/scala/Option.scala | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 5a1c832fae..d263f89bb8 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -211,6 +211,17 @@ sealed abstract class Option[+A] extends Product with Serializable { /** Tests whether the option contains a given value as an element. * + * @example {{{ + * // Returns true because Some instance contains string "something" which equals "something". + * Some("something") contains "something" + * + * // Returns false because "something" != "anything". + * Some("something") contains "anything" + * + * // Returns false when method called on None. + * None contains "anything" + * }}} + * * @param elem the element to test. * @return `true` if the option has an element that is equal (as * determined by `==`) to `elem`, `false` otherwise. @@ -251,16 +262,16 @@ 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"}) + * @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 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}) - * }}} + * // 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 |