Skip to content
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

Update Options.scala to improve clarity with option folding #87

Merged
merged 1 commit into from May 19, 2017

Conversation

KevinGreene
Copy link
Contributor

Using noNumber.fold(0)(_ * 3) makes it unclear whether or not the default value goes through the same process. In other words, is the result 0 because that's the value we provide, or because 0 = 0 * 3?

Using val result2 = noNumber.fold(1)(_ * 3) makes it clearer, as the result is 1 and not 3.

Using `noNumber.fold(0)(_ * 3)` makes it unclear whether or not the default value goes through the same process. In other words, is the result 0 because that's the value we provide, or because `0 = 0 * 3`?

Using `val result2 = noNumber.fold(1)(_ * 3)` makes it clearer, as the result is 1 and not 3.
@KevinGreene KevinGreene changed the title Update Options.scala Update Options.scala to improve clarity with option folding May 5, 2017
Copy link
Contributor

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@juanpedromoreno juanpedromoreno merged commit 2bde75a into scala-exercises:master May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants