https://kotlinlang.org logo
Title
p

pavlospt

08/08/2017, 7:44 AM
Does anyone know the reasoning behind this commit and the changes it introduced? https://github.com/JetBrains/kotlin/commit/5773594412660af11357ac9adc6ffcb45138b840
e

elizarov

08/08/2017, 12:36 PM
@ilya.gorbunov shall know
👍 2
p

pavlospt

08/08/2017, 12:39 PM
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

ilya.gorbunov

08/09/2017, 4:35 PM
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

voddan

08/09/2017, 4:44 PM
@ilya.gorbunov is there a way to participate in this discussion?
i

ilya.gorbunov

08/09/2017, 4:49 PM
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

elizarov

08/09/2017, 5:01 PM
A more interesting case is
3.0 in 1..4
. I, frankly, believe it should be
false
(added that to the issue)
p

pavlospt

08/09/2017, 5:06 PM
Great, thank you for your explanation 🙂