https://kotlinlang.org logo
#announcements
Title
# announcements
n

nfrankel

09/20/2019, 10:05 PM
hello this probably have been asked a million of times how do i efficiently transform a pair into a map.entry asking for a friend 😉
😄 1
r

Ruckus

09/20/2019, 10:11 PM
This sounds like an XY problem to me. It doesn't make any sense to turn them into a map entry if they aren't an entry in a map. Perhaps you need to rethink your flow...
n

nfrankel

09/20/2019, 10:16 PM
the next step of my transform flow requires an entry
r

Ruckus

09/20/2019, 10:33 PM
Right, that's seems like the problem. If the flow requires an entry, that assumes it's getting it's info from a map. You may need to rethink what that flow is doing, and possibly change it to use `Pair`s.
👆 1
Or you might want to look at where the pairs are coming from and see if the logic breaks down there.
If you don't have control over the next step (e.g. it's part of an external API), then what you have is probably pretty good, though I can't imaging why it needs to be internal. Sorry, I was thinking
inner
n

nfrankel

09/20/2019, 10:36 PM
i’m using an external api, it requires an entry the pair i’m creating myself
internal
is because i don’t want to leak it perhaps i’m influenced by my java experience
r

Ruckus

09/20/2019, 10:37 PM
Yeah, my bad. I was thinking
inner
🙂 it makes perfect sense.
n

nfrankel

09/20/2019, 10:38 PM
🙂
thanks for the discussion it’s always good to question
sometimes, it’s so obvious, but not for oneself
r

Ruckus

09/20/2019, 10:41 PM
Agreed. It bugs me when I come across APIs that require
Map.Entry
or similar. It usually means they were too lazy or shortsighted to think through their domain properly.
👆 2
💯 1
2 Views