Does anyone know the reasoning behind this commit ...
# stdlib
p
Does anyone know the reasoning behind this commit and the changes it introduced? https://github.com/JetBrains/kotlin/commit/5773594412660af11357ac9adc6ffcb45138b840
e
@ilya.gorbunov shall know
👍 2
p
Great will wait for his reply then 🙂 thanks @elizarov
@ilya.gorbunov kind ping, if you got some free time to give us an explanation 🙂
i
The reason is that
ClosedRange.contains
is a virtual method, which can be implemented differently in inheritors. We've strived to reimplement
contains
extensions such that they delegated the check to the
contains
member. It turned out that could lead to some weird results related to rounding, as it was mentioned in the issue https://youtrack.jetbrains.com/issue/KT-18938. We're still to discuss what should be the correct behavior in that case.
👍 3
Sorry for the late response, I'm on vacation now.
v
@ilya.gorbunov is there a way to participate in this discussion?
i
I think it would be ok to post arguments in that issue comments.
An interesting case to consider here: should
3.5
be in an IntRange
1..4
given that it's never returned when we iterate values of that range?
e
A more interesting case is
3.0 in 1..4
. I, frankly, believe it should be
false
(added that to the issue)
p
Great, thank you for your explanation 🙂