jeff
02/03/2021, 3:34 AMclass A {
fun B.something() { ... }
}
something()
has two receivers, A and B, yeah?
I was hoping that would let me do this:
class B {
init {
val a = A()
a.something()
}
}
but it seems in reality I have to do this:
class B {
init {
val a = A()
with(a) {
something()
}
}
}
Is there a nicer way to get something closer to the first one?Sanat, Web developer
02/03/2021, 4:39 AMSanat, Web developer
02/03/2021, 7:35 AMNiklas Gürtler
02/03/2021, 2:03 PMread
one socket and it takes a long time for a message to arrive, the thread is blocked and can't read
from another socket, even if data is already available there, so the other socket's can experience poor latency. If you do that on multiple threads, or never need to process I/O simultaneously on multiple sockets anyways, this is moot.holgerbrandl
02/03/2021, 4:51 PMjlleitschuh
02/03/2021, 5:32 PMJurriaan Mous
02/03/2021, 5:38 PMKirill Grouchnikov
02/03/2021, 7:44 PMserebit
02/03/2021, 11:03 PMPatrick Ramsey
02/04/2021, 6:43 AMsupra
02/04/2021, 8:03 AMprivate fun transformDepsRecursively(target: Project, from: Map<*, *>, to: MutableMap<*, *>) {
log.quiet("$TAG transformDepsRecursion start")
from.forEach {
val valueFrom = it.value
var valueTo = valueFrom;
if (valueFrom is ProjectDescriptor) {
valueTo = target.project(valueFrom.path)
} else if (valueFrom is Map<*, *>) {
valueTo = mutableMapOf<String, Any>()
transformDepsRecursively(target, valueFrom, valueTo)
}
to[it.key] = valueTo
}
log.quiet("$TAG transformDepsRecursion end")
}
etibaldi
02/04/2021, 10:51 AMdave
02/04/2021, 12:53 PM> Task :values4k:compileTestKotlin FAILED
e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated
L0
LINENUMBER 17 L0
ALOAD 0
ILOAD 0
INVOKESTATIC Money.constructor-impl (I)I
IRETURN
L1
LOCALVARIABLE this LMoney; L0 L1 0
LOCALVARIABLE value I L0 L1 1
LOCALVARIABLE $constructor_marker Lkotlin/jvm/internal/DefaultConstructorMarker; L0 L1 2
MAXSTACK = 2
MAXLOCALS = 3
File is unknown
nkiesel
02/04/2021, 4:14 PM@JvmInline
annotation before a class declaration for the JVM backend". Is that only required for Java compatibility or do I have to add this to all value/inline classes going forward for all my JVM code, even for 100% Kotlin code?Eugene
02/04/2021, 5:19 PMReinis Muiznieks
02/04/2021, 5:58 PMprivate class InternalParamDefinition {
var id = 0
var type: Byte = 0
var defaultValue: Any? = null
}
object ParamLoader {
@JvmStatic
fun load(id: Int, bytes: ByteArray): ParamDefinition {
fun createInternal(): InternalParamDefinition {
val param = InternalParamDefinition()
param.id = id
val buffer = PacketBuffer(bytes)
while (true) {
when (buffer.unsignedByte) {
0 -> return param
1 -> param.type = buffer.byte
2 -> param.defaultValue = <http://buffer.int|buffer.int>
3 -> param.defaultValue = buffer.string
else -> throw IllegalStateException("unknown field type")
}
}
}
val internalParam = createInternal()
return ParamDefinition(
id = internalParam.id,
defaultValue = internalParam.defaultValue,
type = internalParam.type
)
}
}
I have heard ideas about using Protobuf. Maybe there is some better way to do this?fitzoh
02/04/2021, 6:44 PMJason Ankers
02/05/2021, 4:20 AMval publicFlow: Flow<State> = flowOf(..)
fun doSomething() {
launch {
val localFlow = someService.getStream()
// i want to expose values from localFlow through publicFlow here
}
}
andylamax
02/05/2021, 5:35 AMClass 'tz.co.asoft.IPrinciple' is compiled by an unstable version of the Kotlin compiler and cannot be loaded by this compiler
using kotlin 1.4.30 JVM/IR
Class '<http://tz.co|tz.co>.asoft.IPrinciple'
was compiled by kotlin 1.4.21 JVM/IR. Is this expected?
Do all my dependencies need to be recompiled by 1.4.30?Nikolay Kasyanov
02/05/2021, 8:19 AMpublic
modifier for public interfaces’ methods? It’s not like you can type anything else there anyway, looks redundant.linus muema
02/05/2021, 10:31 AM[Elijah=51, Chloe=144, Natalie=207, Jayden=390, Elizabeth=485, Matthew=485]
In this map, I would like values to be sorted in a descending order first. Then sort the keys in an alphabetical order.
i.e Elizabeth
must appear before Matthew
even though their values are the same.
🤷♂️Kris Wong
02/05/2021, 4:34 PMsuspend
function within runBlocking
, the following code should not be executed until the function completes, correct? I am seeing some flakiness in a test that doesn't make sense to me.Andy Gibel
02/05/2021, 6:06 PMinterface A
and one of interface B
is there a way to write a generic convert function using inline reified
that will convert A to B if and only if a conversion function fun(a) : B
exists?Ali Albaali
02/05/2021, 6:53 PMkotlin.result
in commonMain source set? I tried all the solutions below(in the thread), and it still shows me the error. However it worked on the other targets.WukongRework.exe
02/05/2021, 10:28 PMkotlin.jvm.JvmInline
leads to a This declaration is only available since Kotlin 1.5 and cannot be used with the specified API version 1.4
is there a specific way to get this to work in the playground currently?Kev
02/06/2021, 6:39 AMPOST /endpoint
which requires posted json data to be of a specific json structure. You then mutate this data into something that goes into your database. Where does this mutation take place? On your repository, or something before that and after the endpoint handler?Philipp Mayer
02/06/2021, 12:43 PMHamza GATTAL
02/06/2021, 2:44 PMpoohbar
02/07/2021, 5:15 PMmaven-wrapper
fails to compile my project with this error:
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.4.30:compile (compile) on project my-project: Compilation failure: Compilation failure:
[ERROR] /Users/poohbar/IdeaProjects/my-project/Controller.kt:[23,30] Unresolved reference: of
The line that it fails on looks like this:
val path = Path.of(folder, file)
And replacing it with:
val path = Paths.get(folder, file)
solves the issue.
So bizzarre. 😮Andrew
02/07/2021, 6:45 PM