aljosa
03/27/2020, 9:51 AMSlackbot
03/27/2020, 10:58 AMBulat Mukhutdinov
03/27/2020, 1:10 PMnwillc
03/27/2020, 2:54 PMArdian
03/27/2020, 8:32 PMTim Malseed
03/29/2020, 11:09 AM(SELECT count(*) FROM songs WHERE songs.albumId == albums.id AND songs.blacklisted == 0) as songCount
Tim Malseed
03/29/2020, 11:10 AMcount(distinct songs.id)
(or whatever) syntaxdf
03/29/2020, 4:25 PMinline fun <T> withLoggingContext(map: Map<String, String>, body: () -> T): T {
invoking it like this
withLoggingContext(browserInfo.toMap()) {
logger.warn { "Payment context provides no customer ip address" }
}
leads to following compilation error
Error:(28, 13) Kotlin: None of the following functions can be called with the arguments supplied:
public inline fun <T> withLoggingContext(vararg pair: Pair<String, String>, body: () -> ???): ??? defined in mu
public inline fun <T> withLoggingContext(pair: Pair<String, String>, body: () -> ???): ??? defined in mu
public inline fun <T> withLoggingContext(map: Map<String, String>, body: () -> ???): ??? defined in mu
Help is appreciatediex
03/29/2020, 7:12 PMval foo: Foo = optionalFoo ?: run {
log.e("Not set, can't continue!")
return
}
Rodrigo Silva
03/30/2020, 1:17 AMChills
03/30/2020, 6:39 AMBenjamin Dobell
03/30/2020, 7:32 AMMutableHashMap
, using the keys retrieved from the map itself. Does anyone know how that could be possible?
Attached is a screenshot of the seemingly contradictory debugger outputs.
I should note, this isn’t just an issue with the debugger. In practice I’m inserting a key into a map, then almost immediately retrieving (further up the same call stack) using the exact same key and getting back null
for the value corresponding to that key. There’s no multi-threaded access to this map etc.
hashCode
and equals
are stable for said key.
This is using Jetbrain’s runtime.tyrondis
03/30/2020, 9:55 AMval it = (1..3).circularIterator()
it.next() // 1
it.next() // 2
it.next() // 3
it.next() // 1
// and so on...
Any ideas how I can accomplish this? Is there already something similar in the stdlib?Nikky
03/30/2020, 1:09 PMdave08
03/30/2020, 1:28 PMdata class Something(val somethingElse: SomethingElse, val andAnotherOne: AndAnotherOne)
val something = Something(SomethingElse(), somethingElse.anotherOne)
is there any reason why not (I mean being able to access the first val when initializing the second)? Why shouldn't this be like a regular `val`s inside the class?Volodymyr Chernyshov
03/30/2020, 1:39 PMCLOVIS
03/30/2020, 2:09 PMhdarritchon
03/30/2020, 2:21 PMenum class Content(val value: String) : Serializable {
In java, Enum is serializable by design but not in Kotlin. How would you do it ?Brendan Weinstein
03/30/2020, 5:43 PMJoshua
03/30/2020, 6:24 PMOrhan Tozan
03/30/2020, 7:19 PMHolger Steinhauer [Mod]
03/30/2020, 8:19 PMEllen Spertus
03/30/2020, 10:55 PMprintln((1..100000).map { it * it }.filter { it > 10 }.first())
(My real code doesn’t involve numbers or squaring, just a calculation that I want to stop computing when I get an acceptable result from map
.)iseki
03/31/2020, 12:36 AMnkiesel
03/31/2020, 1:02 AMenum class Type(val value: Int) {
INVALID(-1), SIMPLE(1), COMPLEX(2);
companion object {
private val map = values().associateBy(Type::value)
fun fromInt(value: Int) = map.getOrDefault(value, INVALID)
fun fromString(value: String) = try { valueOf(value) } catch (e: IllegalArgumentException) { INVALID }
}
}
Is there a way to avoid repeating the "companion" part in every enum? Ideally, I would want enum class Type(code: Int) : Magic(code) { INVALID(-1), SIMPLE(1), COMPLEX(2); }
with also some way to identify the INVALID obejct (or just assume it is always the value associated to -1
)LeoColman
03/31/2020, 2:42 AMiseki
03/31/2020, 4:48 AMval
means immutable
or `readonly`?🤔iseki
03/31/2020, 4:53 AMSlackbot
03/31/2020, 11:20 AMhalirutan
03/31/2020, 11:38 AMhalirutan
03/31/2020, 11:38 AMMartin Jinoch
03/31/2020, 11:48 AMarekolek
03/31/2020, 11:57 AMChristian Sousa
03/31/2020, 11:59 AMiseki
03/31/2020, 12:11 PMMartin Jinoch
03/31/2020, 12:30 PMhalirutan
03/31/2020, 1:00 PM