-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Option to cheatsheet #1277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Option to cheatsheet #1277
Conversation
d4a7bcb
to
d4a5c2c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor improvements
if trimmed.length != 0 | ||
upper <- Some(trimmed.toUpperCase) | ||
} yield upper | ||
println(upper.getOrElse(""))</code></pre></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need to println something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required, but it seems useful to show that the value is no longer an Option
. Many of the other examples in the cheatsheet use println
.
maybe add |
I added optionOfOption match {
case Some(Some(x)) => Some(x)
case _ => None
} |
c335b66
to
17e21d8
Compare
17e21d8
to
9b3680c
Compare
9b3680c
to
f09c273
Compare
Give a quick introduction to how
Option
works, and also show many of the useful methods onSome
andNone
and the equivalent pattern match.I removed the use of
Option
from the pattern match section at the begging of the cheatsheet.Preview:
https://ashawley.github.io/docs.scala-lang/cheatsheets/index.html
The original:
https://docs.scala-lang.org/cheatsheets/index.html