Skip to content

Commit 0f07cc1

Browse files
authored
Merge pull request scala#7370 from ashawley/option-doc
Add doc for Option.apply factory
2 parents 503dc14 + f4f3fb6 commit 0f07cc1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/library/scala/Option.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ object Option {
7373
* }
7474
* }}}
7575
*
76+
* Interacting with code that can occasionally return null can be
77+
* safely wrapped in $option to become $none and $some otherwise. {{{
78+
* val abc = new java.util.HashMap[Int, String]
79+
* abc.put(1, "A")
80+
* bMaybe = Option(abc.get(2))
81+
* bMaybe match {
82+
* case Some(b) =>
83+
* println(s"Found $b")
84+
* case None =>
85+
* println("Not found")
86+
* }
87+
* }}}
88+
*
7689
* @note Many of the methods in here are duplicative with those
7790
* in the Traversable hierarchy, but they are duplicated for a reason:
7891
* the implicit conversion tends to leave one with an Iterable in

0 commit comments

Comments
 (0)