Skip to content

Commit fc3d230

Browse files
committed
change examples of flatten and collect
1 parent da08d78 commit fc3d230

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

_overviews/cheatsheets/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ println(upper.getOrElse(""))</code></pre></td>
471471
<td><pre class="highlight"><code>optionOfOption.flatten</code></pre>
472472
<em><strong>same as</strong></em>
473473
<pre class="highlight"><code>optionOfOption match {
474-
case Some(Some(x)) =&gt; Some(x)
475-
case _ =&gt; None
474+
case Some(x: Option[_]) =&gt; x
475+
case None =&gt; None
476476
}</code></pre></td>
477477
<td>Extract nested option.</td>
478478
</tr>
@@ -503,8 +503,7 @@ println(upper.getOrElse(""))</code></pre></td>
503503
<pre class="highlight"><code>option match {
504504
case Some(x)
505505
if f.isDefinedAt(x) =&gt; ...
506-
case Some(_) =&gt; None
507-
case None =&gt; None
506+
case _ =&gt; None
508507
}</code></pre></td>
509508
<td>Apply partial pattern match on optional value</td>
510509
</tr>

0 commit comments

Comments
 (0)