https://kotlinlang.org logo
#splitties
Title
# splitties
i

ispbox

09/22/2019, 8:45 AM
@louiscad What do you think about adding overload for
view.dip()
to be able to deal with floating values where needed. Because without that you have to use your own helper or write extra code:
Copy code
elevation = dip(4).toFloat()
Or dp(4) should be used? I'm just not sure about convention, but for me
dip()
fits better both for float and int.
l

louiscad

09/22/2019, 9:03 AM
@ispbox Yes,
dp
is for that.
i

ispbox

09/22/2019, 10:08 AM
OK, but what is the purpose for having both
dp
and
dip
? What`s wrong with overloading of
dip
?
You can argue that overloads are only possible for different parameter types (now they are both
Int
), but how to make elevation of 3.5f? 🙂 It should be float anyways.
l

louiscad

09/22/2019, 10:12 AM
@ispbox You can't overload based on return type.
i

ispbox

09/22/2019, 10:21 AM
This is what I was saying in my last comment. I would propose these two methods:
Copy code
dip(Int): Int
dip(Float): Float
They could be easily overloaded. The only "problem" is that you have to write:
Copy code
elevation = dip(4f)
But that is not a problem, it is a feature to be able to set floating point elevation, i.e.:
Copy code
elevation = dip(3.5f)
l

louiscad

09/22/2019, 12:26 PM
Hum, I see, could be a great feature, I agree
Just checked the sources, and you convinced me! Do you want to submit a PR on the develop branch or should I do it myself?
i

ispbox

09/22/2019, 12:30 PM
Sorry, Louis, but please do that yourself, as it could influence some other code / public API. I don't know whether you should mark old API as deprecated or something similar (I mean
dp()
).
l

louiscad

09/22/2019, 9:25 PM
@ispbox Now I'm realizing I can equally use
dip
or
dp
. Please vote here: https://kotlinlang.slack.com/archives/CHJP9K00L/p1569187453013900
2 Views