tipsy
07/28/2018, 1:29 AMfor (entry in map) {
if (myValue.startsWith(entry.key)) {
myAction()
return true
}
}
return falsechristophsturm
07/28/2018, 5:37 AMif (map.any { myValue.startsWith(it)} …karelpeeters
07/28/2018, 8:21 AMreturn map.find { (k,v) -> myValue.startsWith(k) } ?. also { myAction() } != nullchristophsturm
07/28/2018, 9:09 AMalso instead of let then it does not matter what the block returnstipsy
07/28/2018, 10:06 AMtipsy
07/28/2018, 10:08 AMtipsy
07/28/2018, 10:09 AMtipsy
07/28/2018, 10:09 AMalso just looks tacked on 🤔tipsy
07/28/2018, 10:11 AMmap.any { myValue.startsWith(it.key) && doAction() } at one point, which seems very hacky, but i actually find it more readable than the alsochristophsturm
07/28/2018, 11:22 AMchristophsturm
07/28/2018, 11:23 AMchristophsturm
07/28/2018, 11:24 AMmap.any {…&& doAction() } is just wrongchristophsturm
07/28/2018, 11:25 AMforEach or map. because its just a side effect that any executes the block on every entry in the maptipsy
07/28/2018, 12:45 PMtipsy
07/28/2018, 12:47 PMkarelpeeters
07/28/2018, 1:20 PMmap.entries.find { ... } then.christophsturm
07/28/2018, 1:44 PMtipsy
07/28/2018, 2:26 PMkarelpeeters
07/28/2018, 2:36 PMalso is maybe a stretch but the find it a lot better IMO.tipsy
07/28/2018, 2:45 PMfind also != nulltipsy
07/28/2018, 2:45 PMtipsy
07/28/2018, 2:45 PMkarelpeeters
07/28/2018, 3:16 PMany and an if on the result.