Big Chungus
02/07/2021, 7:50 PMRodrigo Graciano
02/07/2021, 8:34 PMHenrik Johansson
02/08/2021, 7:46 AMStephan Schroeder
02/08/2021, 11:00 AMKotlin 1.5 removes both constraints: you can now make an interface sealed. The subclasses (both to sealed classes and sealed interfaces) should be located in the same compilation unit and in the same package as the super class, but they can now be located in different files.
Now my question is, can you still extend a sealed interface in a TestCase (within the same module)? Do the tests within a Gradle test
-folder belong to the same sourceSet (and therefore compilation unit?) as the sources under src
?spand
02/08/2021, 1:36 PMkotlinOptions
in gradle for sourcesets other than main
and test
? I have problems setting the `languageVersion`/`apiVersion` for my testFixtures
sourcesetRasmit Devkota
02/08/2021, 6:37 PMkotlinx.serialization compiler plugin is not applied to the module, so this annotation would not be processed. Make sure that you've setup your buildscript correctly and re-import project.
When I add "org.jetbrains.kotlin.plugin.serialization" to the plugins though, it gives me different errors which I don't really understand: java.lang.IllegalStateException: Backend Internal error: Exception during code generation
. For reference, this is in a Jetpack Compose Desktop app, if that has anything to do with the issue. Anyone know the problem?ursus
02/08/2021, 7:49 PMdMusicb
02/09/2021, 1:28 AMwithContext(InjectThreadContext(...)) {
//doStuff
//otherStuff
//moreStuff
}
So this works in the sense that when the coroutine resumes/starts it'll inject our thread context and right after it suspends we have it restore the original context by closing our injected context. But once we reach the end there is no suspend again so the injected context then leaks out of the block whereas we want it to do like a final close.
Is there a different method we should be using?Andrew
02/09/2021, 10:37 AMwhen
expressions? I keep getting a warning telling me it should be exhaustive but I have every possible branch filled in?
I am only seeing this after updating the Kotlin plugin in Android Studio to 1.4.30mending3
02/09/2021, 12:16 PMcharAt
?igor.wojda
02/09/2021, 12:41 PMJoel
02/09/2021, 5:01 PMmending3
02/09/2021, 5:02 PMbuild.gradle
application {
// Define the main class for the application.
mainClass = 'translator.AppKt'
}
task myExecTask(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'translator.AppKt'
args project.getProperty('myFirstArgument') + ' ' + project.getProperty('mySecondArgument');
}
gradle myExecTask -PmyFirstArgument=foo -PmySecondArgument=bar
got error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
---------------------------------------------------------------
how do I pass multiple arguments to gradle?
this doesn't work
gradle run myfirstargument mysecondargument
marzelwidmer
02/09/2021, 6:21 PMKoliners
I want ask about SecurityByDesign
if there better setup how to create the classes https://gist.github.com/marzelwidmer/6aa9733c919f2a8dc6aa84116fe4a580 what I don’t like is… invoke
function is available
data class Customer (val firstName: FirstName, val lastName: LastName, val gender: Gender)
// Domain Primitive
data class FirstName private constructor(val value: String) {
companion object {
// Create Object
operator fun invoke(value: String) = FirstName(validate(value = value))
private fun validate(value: String): String {
check(value.isNotEmpty()) { "value must be non-empty" }
check(value.trim().length >= 2) { "wrong value length" }
check(value.trim().length <= 20) { "wrong value length" }
return value
}
}
}
Travis Griggs
02/09/2021, 7:38 PMmending3
02/10/2021, 5:06 AMstr.charAt(str.length() -1) == ' '
Grigorii Yurkov
02/10/2021, 7:53 AMthis
to S
is unchecked. Is it a bug or I miss somethingAaron nerostarx
02/10/2021, 11:02 AMSourabh Rawat
02/10/2021, 12:35 PMResult<T>
from Java code? My interface returns Result<T>
. i am seeing Object
instead of Result<T>
😕Slackbot
02/10/2021, 12:41 PMnickheitz
02/10/2021, 1:20 PM'@JvmOverloads' annotation cannot be used on constructors hidden by inline class rules
The class in question seems straightforward
class AudioClassifyWorkflowParameters @JvmOverloads constructor(...
I'm not clear how to interpret the error, as I don't know what "hidden by inline class rules" is referring to. Any insight appreciated.Travis Griggs
02/10/2021, 4:36 PManInt.le.ubytes
.
In Swift, I'd accomplish this with something like:
protocol LittleEndianEncodable {
var byteSize:UInt get()
var le:LittleEndianEncoder get()
}
extension LittleEndianEncodable {
var le:LittleEndianEncoder<Self> {
return LittleEndianEncoder(self)
}
}
struct LittleEndianEncoder {
var value:LittleEndianEncodable
var ubytes:Data { // well, Data in Swift
return 0..<self.value.byteSize.map { index in self.value >> (index * 8 ) & 0xFF }
}
}
Or something close to that. Then I'd just add an extension to the existing int classes and be off to the races. But in Kotlin, I can't create a new interface that I then enforce on existing class types. Is there an alternate approach to do this? Basically I want le
to return a "trampoline" object which can return the ubytes
for the object it's wrapped, and do it generically, so I don't have to make individual transformer types for each uint type. I looked through the docs, hoping to find that there was already something that answers the byte size for int types, but didn't see anything 😞Grigorii Yurkov
02/10/2021, 7:18 PMnkiesel
02/10/2021, 9:02 PMimport kotlin.random.Random
enum class Priority { LOW, MEDIUM, HIGH }
fun main() {
val priority = Priority.values()[Random.nextInt(Priority.values().size)]
val s1 = when (priority) {
Priority.LOW -> 1
Priority.MEDIUM -> 2
Priority.HIGH -> 3
}
val s2: Int
if (priority == Priority.LOW) {
s2 = 1
} else {
s2 = when(priority) {
// Priority.LOW -> throw IllegalStateException()
Priority.MEDIUM -> 2
Priority.HIGH -> 3
}
}
println("s1=$s1 s2=$s2")
}
Animesh Sahu
02/11/2021, 3:48 AMMax Härtwig
02/11/2021, 9:43 AMprintln
doesn't seem to show up...David Martinez
02/11/2021, 10:44 AMHenrik Johansson
02/11/2021, 11:48 AMpartap
02/11/2021, 11:52 AMahmad abas
02/11/2021, 12:07 PMahmad abas
02/11/2021, 12:07 PMAli Albaali
02/11/2021, 12:37 PM