Skip to content

Commit 3644e68

Browse files
committed
change examples of flatten and collect
1 parent cd381e2 commit 3644e68

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

_cheatsheets/index.md

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

0 commit comments

Comments
 (0)