-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Minor changes to Animator #3005
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3005 +/- ##
==========================================
+ Coverage 19.64% 19.68% +0.04%
==========================================
Files 113 113
Lines 13792 13762 -30
==========================================
Hits 2709 2709
+ Misses 11083 11053 -30
Continue to review full report at Codecov.
|
phaseY = Double(elapsed / duration) | ||
} | ||
|
||
phaseY = _easingY?(elapsed, duration) ?? elapsed / duration |
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.
I think using if let
here instead of a one-liner here would be more readable
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.
I disagree on this one. ??
is a very common operator in Swift (it's all over the stdlib). Would you prefer something like
phaseY = _easingY?(elapsed, duration)
?? elapsed / duration
or
phaseY = _easingY?(elapsed, duration) ??
elapsed / duration
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 also worth noting that on #2698 there were many cases of this being approved, including this line (thought it was written as phaseY = _easingY?(elapsed, duration) ?? Double(elapsed / duration)
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.
My problem is not with the ?? My problem is with the optional closure. I think It would be clearer to unwrap it first with if let
before calling it. It is minor though. It’s up to you.
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.
I would agree with you in a case like:
let x = myFuncWithNonEscaping? {
// Logic
} ?? myDefaultValue
But in this case I really think this is okay.
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.
I find it cluttered but it doesn’t really matter.
No description provided.