Daniele B
06/02/2021, 2:05 PMmyList.removeAll { it.myField != myFieldValue }
But for a map, there doesn’t seem to be removeAll
:
myMap.removeAll { it.key != myKeyValue } <--- removeAll doesn't exist
what should I use instead?Zun
06/06/2021, 1:41 PMJustin Yue
06/08/2021, 2:20 AMCLOVIS
06/08/2021, 8:51 AM@JvmInline
, and says I should add kotlin-stdlib:1.4.31
to the class path. Is there something hidden somewhere in the settings?rtsketo
06/09/2021, 12:56 PMconstructor(aList : List<A>) /* Main constructor */
constructor(bList : List<B>) : this (bList.toListA())
I get the following:
Platform declaration clash: The following declarations have the same JVM signature ((Ljava/util/List;)V):
How do I distinguish between them?Tarun Chawla
06/10/2021, 6:57 AMimport org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
plugins {
kotlin("multiplatform") version "1.5.10"
kotlin("plugin.serialization") version "1.5.10"
application
}
group = "tech.tarunchawla"
version = "0.0.1"
repositories {
jcenter()
mavenCentral()
maven { url = uri("<https://dl.bintray.com/kotlin/kotlin-js-wrappers>") }
maven { url = uri("<https://dl.bintray.com/kotlin/kotlinx>") }
maven { url = uri("<https://dl.bintray.com/kotlin/ktor>") }
maven("<https://dl.bintray.com/konform-kt/konform>")
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
testRuns["test"].executionTask.configure {
useJUnit()
}
withJava()
}
js(LEGACY) {
browser {
binaries.executable()
webpackTask {
cssSupport.enabled = true
}
runTask {
cssSupport.enabled = true
}
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
sourceSets {
val commonMain by getting {}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
implementation("io.ktor:ktor-server-netty:1.6.0")
implementation("io.ktor:ktor-html-builder:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2")
implementation("io.ktor:ktor-gson:1.6.0")
implementation("io.ktor:ktor-auth:1.6.0")
implementation("io.ktor:ktor-auth-jwt:1.6.0")
implementation("io.ktor:ktor-serialization:1.6.0")
implementation("org.postgresql:postgresql:42.2.20")
implementation("org.jetbrains.exposed:exposed-core:0.31.1")
implementation("org.jetbrains.exposed:exposed-jdbc:0.31.1")
implementation("org.jetbrains.exposed:exposed-java-time:0.31.1")
implementation("com.auth0:java-jwt:3.10.3")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("org.xerial:sqlite-jdbc:3.34.0")
}
}
val jsMain by getting {
dependencies {
implementation("io.ktor:ktor-client-js:1.6.0")
implementation("io.ktor:ktor-client-serialization:1.6.0")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react:17.0.2-pre.206-kotlin-1.5.10")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:17.0.2-pre.206-kotlin-1.5.10")
implementation(npm("react", "17.0.2"))
implementation(npm("react-dom", "17.0.2"))
implementation("org.jetbrains.kotlin-wrappers:kotlin-styled:5.3.0-pre.206-kotlin-1.5.10")
implementation(npm("styled-components", "~5.3.0"))
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-router-dom:5.2.0-pre.206-kotlin-1.5.10")
implementation("org.jetbrains.kotlin-wrappers:kotlin-redux:4.0.5-pre.206-kotlin-1.5.10")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-redux:7.2.3-pre.206-kotlin-1.5.10")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1")
implementation("io.konform:konform-js:0.2.0")
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
application {
mainClass.set("MainKt")
}
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "MainKt"
}
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack") {
outputFileName = "output.js"
}
tasks.getByName<Jar>("jvmJar") {
dependsOn(tasks.getByName("jsBrowserProductionWebpack"))
val jsBrowserProductionWebpack = tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack")
from(File(jsBrowserProductionWebpack.destinationDirectory, jsBrowserProductionWebpack.outputFileName))
}
tasks.getByName<JavaExec>("run") {
dependsOn(tasks.getByName<Jar>("jvmJar"))
classpath(tasks.getByName<Jar>("jvmJar"))
}
Ben Nash
06/10/2021, 10:05 PMMorgan
06/12/2021, 12:49 PMthhh
06/15/2021, 1:32 PMthread { ... }
in this code: https://pastebin.com/d9xvi3ay
When using thread
Timber Logging library incorrectly assigns Tag. Like even when using Timber.d from Acitivity or other class, it will show Tag of Application class (where Timber is initialized)Daniele B
06/16/2021, 9:16 AMsuspend fun getMyObject() : MyObject {
...
return myObject
}
val myApp = myCallback { myObject ->
/* code using myObject */
}
how should I write the function myCallback
?Scott Wilson-Billing
06/16/2021, 4:44 PMScott Wilson-Billing
06/16/2021, 4:48 PMJack W
06/16/2021, 5:01 PMtrofman
06/18/2021, 6:28 AMsome.thing.like
as one
without doing val one = some.thing.like
?Slackbot
06/21/2021, 9:22 AMalexeenkoff
06/21/2021, 9:54 AMlocalizedDescription
- best way to differ exceptions?hoang
06/23/2021, 7:50 AMPeter
06/23/2021, 1:42 PMoperator fun SomeClass.minus(b: SomeClass) = minus(b)
Manuel Pérez Alcolea
06/25/2021, 3:46 AMMyClass
and an interface MyInterface
and have several classes extending and implementing them, Kotlin infers both the class and the interface in generic types. For example val list = listOf(ImplemA(), implemB())
contains objects that are MyClass
and comply with MyInterface
. IDEA describes the bound as <{MyClass & MyInterface}>
in that case. Can I specify a type like that explicitly, without creating a new class? What's the catch?Matias Reparaz
06/25/2021, 12:53 PMSanendak
06/26/2021, 4:52 PMkierans777
06/29/2021, 4:41 AMfun doSomething(): (Class<T>) -> T {}
However because lambda expressions can't have generic types, this doesn't compile for me.Vitaliy Zarubin
06/30/2021, 9:30 AModay
07/01/2021, 5:00 PMtipsy
07/02/2021, 10:47 AMDMITRY.
07/04/2021, 2:41 PMLqncer
07/04/2021, 6:08 PModay
07/04/2021, 7:07 PMtypealias Visitor<T> = (TreeNode<T>) -> Unit
mean, “any function that takes TreeNode<T> and return Unit can now be referred to as Visitor<T>
?
so instead of writing
fun search(printResult: (TreeNode<T>) -> Unit)
I write fun search(visit: Visitor<T>)
tipsy
07/05/2021, 8:22 PMinline fun <reified T : Any> queryParam(key: String) = ...
fun queryParam(key: String) = ...
in kotlin this works fine, but both mockk and mockito get confused, it's random which one of the methods get picked. is there any way of dealing with this?oday
07/06/2021, 9:04 AMinterface Stack<T : Any>
and
interface Stack<T>
?
T
already means literally anythingoday
07/06/2021, 9:04 AMinterface Stack<T : Any>
and
interface Stack<T>
?
T
already means literally anythingMatteo Mirk
07/06/2021, 9:08 AMT : Any?
so includes nullable types. Your first declaration excludes nullable types from the domain.oday
07/06/2021, 9:10 AMT
, feeding that T
back to Stack<T> will complainMatteo Mirk
07/06/2021, 9:20 AModay
07/06/2021, 9:20 AMMatteo Mirk
07/06/2021, 9:23 AMStack<Int?>
if you used the first definition, right?oday
07/06/2021, 9:25 AM