Skip to content

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
@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