Dominick
04/23/2021, 1:57 AM<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
I don't understand why I get this error. If anyone has insight or a fix please share!dave08
04/23/2021, 9:17 AMspand
04/23/2021, 1:03 PMallWarningsAsErrors = true
for all my modules regardless of them being, common, multiplatform-js, multiplatform-jvm, kotlinjs, kotlin ect. Is this the right type to search for ?
subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.class) {
kotlinOptions {
allWarningsAsErrors = true
}
}
}
Slackbot
04/23/2021, 5:11 PMDominaezzz
04/24/2021, 9:19 AMval myNum: Int = 5
val myBigNum: Long = myNum // fine
val myMaybeBigNum: Long? = myNum // not fine
F0X
04/24/2021, 9:37 AM0xFF
and have that be converted to a signed Byte
Yaniv Sosnovsky
04/24/2021, 3:11 PM{"drinks":[{"strDrink":"Jelly Bean","strDrinkThumb":"https:\/\/<http://www.thecocktaildb.com|www.thecocktaildb.com>\/images\/media\/drink\/bglc6y1504388797.jpg","idDrink":"13775"},{"strDrink":"Turf Cocktail","strDrinkThumb":"https:\/\/<http://www.thecocktaildb.com|www.thecocktaildb.com>\/images\/media\/drink\/utypqq1441554367.jpg","idDrink":"12418"}]}
but sometimes the server returns the following:
"{"drinks":"None Found"}"
Before using kotlinx I had a custom type convertor with Gson, and that worked fine, but I’m struggling with kotlin.
I tried to create a KSerializer to try to parse the result, and return an object with an empty list if an exception is thrown, but I keep getting this exception:
java.lang.IllegalStateException: Reader has not consumed the whole input: JsonReader(source='{"drinks":"None Found"}', currentPosition=22, tokenClass=1, tokenPosition=10, offset=11)
Any ideas how to solve this? I can always return a string instead of a data class, but this is ugly AFMichael
04/26/2021, 7:29 AMuser
04/26/2021, 8:40 AMStephan Schroeder
04/26/2021, 11:27 AMalgo112
04/26/2021, 1:40 PMval listType = object : TypeToken<List<Cookie>>() {}.type
val encodedCookie = sharedPreferences.getString(url.host, null)
val cookies: List<Cookie>? = encodedCookie?.run { gson.fromJson(encodedCookie, listType) }
return cookies ?: ArrayList()
stanislav.erokhin
ursus
04/26/2021, 5:19 PMDavid Smith
04/26/2021, 8:52 PMBig Chungus
04/26/2021, 10:11 PMursus
04/26/2021, 11:24 PM@OptIn
?ursus
04/27/2021, 2:19 AMe: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during psi2ir
File being compiled: C:/Users/ursus/AndroidStudioProjects/o2-selfcare-android/complex-syncer/contract/src/main/java/sk/o2/complex/Mappers.kt
The root cause java.lang.NullPointerException was thrown at: org.jetbrains.kotlin.psi2ir.generators.BodyGenerator.generateSuperConstructorCall(BodyGenerator.kt:242)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
at org.jetbrains.kotlin.psi2ir.generators.DeclarationGenerator.generateMemberDeclaration(DeclarationGenerator.kt:78)
at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateSingleFile(ModuleGenerator.kt:83)
at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateModuleFragment(ModuleGenerator.kt:50)
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:81)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:140)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:66)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:61)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:592)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:212)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:155)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
Muhammad Zaryab Rafique
04/27/2021, 4:28 AMMichael Böiers
04/27/2021, 5:58 AMdata class A(var b: B? = null)
data class B(var a: A? = null)
fun main() {
val a = A()
val b = B(a).also { a.b = it }
println(a) // produces StackOverflow as the two toString impls call each other indefinitely
}
I suppose this is unavoidable - nevertheless, it can kill an application merely by converting a plain Java class into a data class. Any thoughts?PHondogo
04/27/2021, 9:47 AMthanksforallthefish
04/27/2021, 12:40 PMKarlo Lozovina
04/27/2021, 3:19 PMlatinit
properties after they've been initialized? Something in the stdlib maybe?Quincy
04/27/2021, 7:34 PMStream.of(...)
.toMap(
keySelector,
valueTransform,
(x, y) -> {
if (x.getTimestamp().isBefore(y.getTimestamp())) return x;
else return y;
});
If there would be duplicate values then the third argument determines what to do about it. In Kotlin, the associateBy
function always keeps the most recent value. Is there a way to create a map the way Java does, where I get to decide what to do with duplicates?Karlo Lozovina
04/27/2021, 7:46 PMblakelee
04/27/2021, 10:08 PMenum class Page {
PAGE_1,
PAGE_2;
}
enum class Page1Section {
SECTION_A,
SECTION_B
}
enum class Page2Section {
SECTION_1,
SECTION_2
}
With my end goal being something like
Page.PAGE_1.SECTION_A.build()
and if I selected PAGE_2 then
Page.PAGE_2.SECTION_1.build()
Maybe this would be better in sealed classes
If I selected PAGE_1, if I were to type .
then I would get the list of Page1Section's then if I click .
again perhaps another list of itemsChuck Canning
04/27/2021, 11:13 PMDavid Smith
04/28/2021, 12:42 AMhashCode()
already but I want to avoid having to call it as a function because during a diff of a deeply nested structure this could happen many many times, i.e. I want to memoize the call. Can I simply add a property that is initialized to this.hashCode()
? I’ve implemented the following which seems to work (although I haven’t tested it properly yet)
sealed class Node {
data class TextNode(val value: String) : Node() {
override val hash = this.hashCode()
}
data class TagNode(val name: String, val attributes: List<Attribute>, val children: List<Node>) : Node() {
override val hash = this.hashCode()
}
abstract val hash: Int
}
amr s
04/28/2021, 2:39 AMCLOVIS
04/28/2021, 7:47 AMtailrec suspend
to work, but it does! Thanks to the team, that must have been a weird edge case to handle.jim
04/28/2021, 6:14 PMit.
?
kotlin
val a = "1 2\n3 4".lines().map{CharSequence::split("\\s+".toRegex())}
log
Matrix.kt: (10, 59): This syntax is reserved for future use; to call a reference, enclose it in parentheses: (foo::bar)(args)
e: /home/a/github/exercism/kotlin/matrix/src/main/kotlin/Matrix.kt: (10, 54): Overload resolution ambiguity:
public fun CharSequence.split(regex: Pattern, limit: Int = ...): List<String> defined in kotlin.text
public fun CharSequence.split(vararg delimiters: String, ignoreCase: Boolean = ..., limit: Int = ...): List<String> defined in kotlin.text
public fun CharSequence.split(vararg delimiters: Char, ignoreCase: Boolean = ..., limit: Int = ...): List<String> defined in kotlin.text
@InlineOnly public inline fun CharSequence.split(regex: Regex, limit: Int = ...): List<String> defined in kotlin.text