-
Notifications
You must be signed in to change notification settings - Fork 6
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
Equality definition #7
Comments
This is actually by design, to ensure that statements like: Given these issues, I don't see how this change could be the right thing to do. For your case, is it possible to trigger on the unit itself instead of the Measure? I don't know Compose well, but could you isolate the unit specified by the user and trigger recomposition on that? |
Well, the problem with the comparisons is, that you are comparing floating point values. They should be avoided as they are unreliable. Even in your example,
Yes, that's basically my only option right now. I was trying to avoid it though, as it is easy to forget about this behaviour and prone to future bugs. I understand you are not keen on changing the equality implementation. I wanted to open this discussion anyways to get your input. I will maybe fork this repository and make the changes for myself. |
Yeah, the equality issues between floating point values is unavoidable. I've considered providing a way to use That said, the behavior of equality feels more intuitive in that it treats a |
Hello,
I have noticed that the
equals
function onMeasure
class returns true even when the units of two measurements are different.This is how Swift defines equality in their Measurement too.
However, I have encountered an issue with this implementation using Compose, where my UI is not recomposed when changing units.
I wonder whether it is correct or not to consider the units in the equality function. Was there a particular decision for the current implementation?
If
equals
were to include the units in the comparison, we could still use thecompareTo
as an alternative for the old behaviour.The text was updated successfully, but these errors were encountered: