-
Notifications
You must be signed in to change notification settings - Fork 200
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
Optional #1143
Comments
@Masynchin indeed, you are right. I can't remember why |
@yegor256 I am planning this refactor:
It extends both class OptionalEnvelope extends Opt, Optional {
private final Optional origin;
get() { origin.get() }
has() { origin.isPresent() }
// ...all Optional methods delegated to `origin`
}
Since it is both
We can both replace it with
After deleting What do you think? |
@Masynchin you are planning to submit four pull requests? |
@yegor256 No, just one PR - "Replace Opt with Optional". This is just a step-by-step plan. Does this plan have any issues? If it seems OK, I can start implementing it. |
It turned out I can't just create |
Hello, @yegor256!
Why don't this project use
Optional
, but rather implements its ownOpt
? I think thatOptional
can safely replaceOpt
and also bringmap
method, which can be used to get rid ofif opt.has() { /* do something with opt.get() */ } else { return Opt.Empty() }
.For example, this method
takes/src/main/java/org/takes/facets/auth/PsBasic.java
Lines 238 to 261 in 91d020c
Can be rewrite like this:
It uses two less variables and one less
if-else
statement. I think this code is more readable and more maintainable.The text was updated successfully, but these errors were encountered: