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

Add Opt.when method #560

Merged
merged 1 commit into from
Apr 10, 2024
Merged

Add Opt.when method #560

merged 1 commit into from
Apr 10, 2024

Conversation

halotukozak
Copy link
Member

Opt.when is similar to optIf, but takes Opt[?] parameter. The inspiration came from Task.when.

It may simplify code like this:

if (predicate(sth)) sthElse.orElse(sthMoreElse.map(_.sth)) else Opt.Empty

to

Opt.when(predicate(sth)){ sthElse.orElse(sthMoreElse.map(_.sth)) }

@halotukozak halotukozak requested a review from ddworak April 9, 2024 10:12
@halotukozak halotukozak force-pushed the opt-when branch 5 times, most recently from e90be97 to cec85fc Compare April 9, 2024 13:24
@halotukozak halotukozak force-pushed the opt-when branch 2 times, most recently from bf9646e to 9e6f3e6 Compare April 10, 2024 06:58
Copy link
Member

@ddworak ddworak left a comment

Choose a reason for hiding this comment

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

LGTM after nits.

@sebaciv do you want to take a final look?

@ddworak ddworak merged commit e630f64 into master Apr 10, 2024
7 checks passed
@ddworak ddworak deleted the opt-when branch April 10, 2024 08:57
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.

4 participants