Ruckus
09/16/2020, 3:02 PMzeugederunity
09/16/2020, 3:45 PMSerialName
annotation was set to retention(BINARY)
Is there any way in Kotlin 1.4 to retrieve the SerialName
of an annotated property? Because the way by reflection is now lost.Marc Knaup
09/16/2020, 6:39 PMconst
?
I.e. (FooFeature as Feature).id
uses the property getter and FooFeature.id
uses the compile-time constantweber de lima santos
09/16/2020, 8:22 PMRobert Menke
09/16/2020, 8:26 PMlaith
09/16/2020, 9:50 PM((String) -> String)::class
myaa
09/17/2020, 12:13 AMunresolved reference: value
for the is Match.HasMatch
line
sealed class Match {
object NoMatch : Match()
class HasMatch(value: Int) : Match()
}
fun main() {
val x: Match? = null
when (x) {
Match.NoMatch -> println("no match")
is Match.HasMatch -> println("value: ${x.value}")
null -> println("null")
}
}
Justin
09/17/2020, 4:15 AMkotlinx.cli
)?
The app itself looks pretty typical, e.g.:
fun main(args: Array<String>) {
// Do stuff that might exit with status code 0 or 1
}
My (apparently wrong) instinct was to write tests like:
@Test fun testExitsWithoutError() {
val result = main(args)
assertEquals(0, result)
}
But main
can only return void
. How do I write tests that can pass args into main and expect a certain result?Brett Best
09/17/2020, 9:49 AMKurt Renzo Acosta
09/17/2020, 10:44 AMdata class Model(
val a: String,
val b: String,
val nullableOnlyForStateA: String?,
val state: State,
val propForStateA: String?,
val propForStateB: String?
)
I’m trying to use sealed classes to make it more idiomatic but it seems too verbose:
sealed class Model {
abstract val a: String
abstract val b: String
abstract val nullableOnlyForStateA: String?
data class A(
override val a: String,
override val b: String,
override val nullableOnlyForStateA: String?,
val propForStateA: String
) : Model()
data class B(
override val a: String,
override val b: String,
override val nullableOnlyForStateA: String,
val propForStateB: String
) : Model()
}
This seems okay but my original class has much more properties and more states making a 16-line data class turn into a more-than-100 line sealed class. Any ideas on how to make this more ergonomic?Will Nixon
09/17/2020, 2:40 PMMgj
09/17/2020, 3:09 PM@Serializable
data class MyDataClass(
val myProp: String?
)
... will throw kotlinx.serialization.MissingFieldException: Field 'myProp' is required, but it was missing
if the json does not contain the myProp
key. I really dont want to add a default value of null
to every single optional fieldRoger Sala
09/17/2020, 3:27 PMuser
09/17/2020, 3:30 PMKarlo Lozovina
09/17/2020, 10:21 PMwhen
condition without binding it to a name? some sort of default provided name? For example in the code below, is it possible to write it without the temp
variable?:
val temp = foo.bar.getBaz()
when (temp) {
is A -> print(temp)
is B -> ...
}
Colton Idle
09/18/2020, 3:16 AMKayCee
09/18/2020, 3:52 AMDaniel Svensson
09/18/2020, 6:55 AMelect
09/18/2020, 8:03 AMjava.lang.LinkageError: loader constraint violation: when resolving method "imgui.ImGui.begin(Ljava/lang/String;Lkotlin/reflect/KMutableProperty0;I)Z" the class loader (instance of net/fabricmc/loader/launch/knot/KnotClassLoader) of the current class, net/aaa/bbbb/gui/screen/ModScreen, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, imgui/ImGui, have different Class objects for the type kotlin/reflect/KMutableProperty0 used in the signaturesince he updated from 1.4.0 to 1.4.10, has anyone encountered something similar?
Isaac
09/18/2020, 11:10 AMgradle.properties
file and got a reference in the build.gradle.kts
file by declaring a global property:
val api_key: String by project
. I want to use api_key
in my Main.kt
, but I can't seem to figure out how to gain access. Searched on StackOverflow and all the results were android related. Can anyone help?spand
09/18/2020, 2:43 PMfoo2
,foo3
?
interface Foo {
fun bar()
}
private val foo: Foo = object : Foo {
override fun bar() {
TODO("Not yet implemented")
}
}
private val foo2: Foo = {}
private val foo3: Foo = Foo {}
andylamax
09/18/2020, 2:56 PMLeoColman
09/18/2020, 2:57 PMNir
09/18/2020, 3:34 PMmap
with your own that returns an ImmutableList instead of a List. How would you do it?Vivek Subramanian
09/18/2020, 5:07 PMShawn
09/18/2020, 5:09 PMNir
09/18/2020, 7:01 PMimplementation "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.3"
to my gradle file, but it still can't seem to import. How should I debug this?Simon Kågedal Reimer
09/19/2020, 7:22 PMfun myCallback(@Suppress("UNUSED_PARAMETER") someValue: Int) { }
Nir
09/20/2020, 2:21 AMfoo
imports bar.blub
, i want it to to be so that if somoene does import foo.*
they also get blub.Ayden
09/20/2020, 3:15 PM