nfrankel
07/06/2020, 1:14 PMwhile (shorteneds.putIfAbsent(url, this) != null) {}
of course, intellij complains that the block is empty
any idea how to write a better version without the complaint?
i’m probably missing something from stdlib...diesieben07
07/06/2020, 1:16 PMwhile (shorteneds.putIfAbsent(url, this) != null) {
// intentionally empty
}
Jurriaan Mous
07/06/2020, 1:17 PMwhile (shorteneds.putIfAbsent(url, this) != null) Unit
nfrankel
07/06/2020, 1:19 PMdiesieben07
07/06/2020, 1:19 PMUnit
is completely meaningless here, btw.
while (something) Int
does the same thingnfrankel
07/06/2020, 1:28 PMInt
raises my eyebrow
while with Unit
i can understand the reasonnatpryce
07/06/2020, 1:38 PMjw
07/06/2020, 1:54 PMnfrankel
07/06/2020, 2:15 PMCheolho Jeon
07/06/2020, 2:31 PMvar result: Any?
do {
result = shorteneds.putIfAbsent(url)
} while(result != null)
// or
var result = shorteneds.putIfAbsent(url)
while (result != null) {
result = shorteneds.putIfAbsent(url)
}
because for me the while loop works like while (condition) do {action}
. not while(condition - and - action)
. If you know what I mean..