Gunslingor
08/23/2020, 1:08 AMfrank
08/23/2020, 8:37 AMfun getParentPath(son :String) : Path {
val parent = Paths.get(son).parent
return parent?.let {
if (Files.exists(parent))
parent
else null // need alternative
} ?: null // need alternative
}
Rohan Maity
08/23/2020, 10:19 AMMap<String,My_Info_Class>
during annotation processing. So Map is created during compile time. Is there any way I could access the same Map object
I created in Different module ?Sam
08/23/2020, 3:09 PMvar data = false
@Synchronized get
@Synchronized set(value) { field = !value }
fun main() {
println("Value $data")
}
The only way to get bytecode to call getData() is by having this redundant get (which is prompted as redundant getter in IDE)
@Synchronized get() = field
melatonina
08/23/2020, 7:54 PMdf
08/23/2020, 9:14 PMNikky
08/24/2020, 12:46 AMalwyn
08/24/2020, 1:18 AMcontentEquals
method on classes like ByteArray, IntArray
have been marked as deprecated. I am used to the Java world where a deprecation usually goes hand in hand with information on what can be used as an alternative.
Does anyone know what can be used to compare the contents of arrays instead of contentEquals?
It looks like this functionality eventually calls through to java.util.Arrays.equals which takes nullable values. So maybe this is to indicate that ByteArray?.contentEquals
is supposed to be called and eventually the other version will just be dropped. Why not just drop it anyway in 1.4.0 already since it should just 'work'?Jukka Siivonen
08/24/2020, 9:18 AMuser
08/24/2020, 11:20 AMRob Elliot
08/24/2020, 3:42 PMdata class A(
val b: B
) {
data class B(
val c: C
) {
data class C(
val foo: String,
val bar: Int
)
}
}
I find myself hankering after a more concise way of doing the same thing; something like:
data class A(
val b: data class B(
val c: data class C(
val foo: String,
val bar: Int
)
)
)
I imagine those as being completely interchangeable - so the type of A.b.c
is A.B.C
.
What do you think?stephanmg
08/24/2020, 3:49 PMSteve
08/24/2020, 4:36 PMVictor Harlan Lacson
08/25/2020, 12:51 AMbuild.gradle.kts
below,
but it is not creating a runable jar
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
kotlin("multiplatform")
java
application
id("com.github.johnrengelman.shadow") version ("5.2.0")
}
group = "com.kotlin.mpf.server"
version = "1.0-SNAPSHOT"
val ktorVersion = "1.4.0"
repositories {
//repos
}
kotlin {
sourceSets {
jvm().compilations["main"].defaultSourceSet {
dependencies {
//--dependencies
}
}
}
}
application {
mainClassName = "com.vhl.inventory.server.MainKt"
}
tasks.withType<ShadowJar> {
baseName = "kotlin-mpf-runnable"
classifier = null
version = null
}
when ever i try to run the created fat jar, follows an error below
java -jar fat.jar
Error: Could not find or load main class com.vhl.inventory.server.MainKt
Caused by: java.lang.ClassNotFoundException: com.vhl.inventory.server.MainKt
has anyone done runnable jar in multi-platform projectTolriq
08/25/2020, 7:05 AMxii
08/25/2020, 11:58 AMsnowe
08/25/2020, 5:59 PM@Nonnull
String[] createSfdcObjects(@Nonnull final SObject... sfdcObjects);
mock looks like whenever(sfdcCrudService.createSfdcObjects(anyVararg()))...
, but it always returns null. I've tried every matcher (any
, anyOrNull
, etc) and none of them match. What am I missing?Philipp Mayer
08/25/2020, 7:03 PMVampire
08/25/2020, 7:14 PM.kt
file with an object expression in it to the actual instance?
Like with using K2JVMCompiler
for example?
Are there any examples for that?TwoClocks
08/26/2020, 1:02 AMJakekudur
08/26/2020, 3:18 AMSimon Lin
08/26/2020, 7:07 AMval jobA = Job()
val jobB = GlobalScope.launch(jobA) {
delay(1000L)
println("World!")
}
What is the different between jobA
and jobB
?
If I would like to cancel the Job, which one need to be called? jobA.cancel()
or jobB.cancel()
?Erik
08/26/2020, 8:17 AM?
as an expression suffix to coerce the expression to be of nullable type?
Examples:
var x = 1?
-> inferred type = Int?
, so no need to type var x: Int? = 1
. Later you can always set x = null
.
someQuery()?
-> inferred type = nullable return type of someQuery()
. If that function already returns a nullable type, then a linter warning should be shown that the ?
suffix is redundant.Marc Knaup
08/26/2020, 10:56 AMpublic inline fun <C, R> C.ifEmpty(defaultValue: () -> R): R where C : CharSequence, C : R =
if (isEmpty()) defaultValue() else this
But when copy&pasting that code it doesn’t even compile!
Type parameter cannot have any other bounds if it’s bounded by another type parameterIs it safe to silence that error? 😮
Patrick Doering
08/26/2020, 1:23 PMblackstardlb
08/26/2020, 1:54 PMpoohbar
08/26/2020, 2:49 PMinterface Animal {
val id: String
fun <T: Animal> withSound(sound: String): T
}
data class Dog(
override val id: String
): Animal {
// works
override fun <T : Animal> withSound(sound: String): T {
TODO("Not yet implemented")
}
// does not work
override fun withSound(sound: String): Dog {
TODO("Not yet implemented")
}
}
poohbar
08/26/2020, 3:23 PMwithSound()
should return the same type as it is defined inzak.taccardi
08/26/2020, 4:42 PMList<T>.join(..)
function?bbaldino
08/26/2020, 9:26 PM.any { it > bigEnoughNum }
first, but then if that returns false I have to iterate again to find the actual max, which doesn't seem efficient.bbaldino
08/26/2020, 9:26 PM.any { it > bigEnoughNum }
first, but then if that returns false I have to iterate again to find the actual max, which doesn't seem efficient.nanodeath
08/26/2020, 9:27 PMiterable.first { it > bigEnoughNum }
?bbaldino
08/26/2020, 9:28 PMany
method? If it fails I'd still have to iterate over the whole list to find the max.nanodeath
08/26/2020, 9:28 PMfirstOrNull
or find
the same exact waybbaldino
08/26/2020, 9:29 PM> bigEnoughNum
ephemient
08/26/2020, 9:30 PMiterable.maxByOrNull {
if (it > bigEnoughNum) return
it
}
will break earlybbaldino
08/26/2020, 9:31 PMnanodeath
08/26/2020, 9:32 PMfirst
? I'm still unclear why that doesn't workNir
08/26/2020, 9:32 PMval x = listOf(1,10,11)
println(x.maxByOrNull { if (it > 8) return@maxByOrNull it else it })
bbaldino
08/26/2020, 9:40 PMreturn@maxByOrNull
is the same as the normal return that happens thereNir
08/26/2020, 9:43 PMprintln(run { x.maxByOrNull { if (it > 8) return@run it else it }!! })
bbaldino
08/26/2020, 9:46 PMNir
08/26/2020, 9:48 PMfun <T: Comparable<T>> Iterable<T>.maxOrOver(threshold: T) = this.maxByOrNull { if (it > threshold) return it else it}!!
ephemient
08/26/2020, 10:07 PMinline fun <T: Comparable<T>> Iterable<T>.firstOrMaxOrNull(
crossinline predicate: (T) -> Boolean
): T? = maxByOrNull { if (predicate(it)) return it else it }
not sure how general it should be, though. seems pretty specializedstreetsofboston
08/26/2020, 10:15 PMbbaldino
08/26/2020, 10:16 PMephemient
08/26/2020, 10:22 PMbbaldino
08/26/2020, 10:28 PMNir
08/26/2020, 10:38 PMephemient
08/27/2020, 12:09 AMNir
08/27/2020, 12:22 AMmap
which are implemented for both (but with the differences you mentioned)