savrov
11/04/2020, 11:49 PMrepositories {
jcenter()
maven { url = uri("<https://dl.bintray.com/ekito/koin>") }
}
and
dependencies {
implementation("org.koin:koin-core:3.0.0-alpha-4")
}
I’m ok with that, but the thing I don’t understand, why I have to add a repository block to C module as well, while I don’t have a dependency on that lib in C module? Thank you in advance.Scott Christopher
11/05/2020, 12:49 AMjava.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/example/Foo.bar(Lkotlin/jvm/functions/Function3;)Lcom/example/Other$ThingConsumer; @13: invokespecial
Reason:
Type 'kotlin/jvm/functions/Function3' (current frame, stack[3]) is not assignable to 'kotlin/jvm/internal/Ref$ObjectRef'
when attempting to use:
runBlocking { consumer(connection, event) }
where consumer: suspend (Connection, Event) -> Unit
is passed into the function calling runBlocking
.
We can hack around it by replacing it with something like GlobalScope.async { consumer(connection, event) }.asCompletableFuture().get()
but it's less than ideal 😬
This is using Kotlin 1.4.10 and kotlinx.coroutines 1.4.0.
Any thoughts?Ifvwm
11/05/2020, 4:01 AMPaul Woitaschek
11/05/2020, 8:04 AMexplicitApi
?
I want to enable it for a library but that library also exposes generated classes by sqldelight and I'd like to not fail the compilation on generated classes.Kerem Aslan
11/05/2020, 11:15 AMreduce
signature is like:
inline fun <S, T : S> Array<out T>.reduce(
operation: (acc: S, T) -> S
): S
While the fold
signature is like:
inline fun <T, R> Array<out T>.fold(
initial: R,
operation: (acc: R, T) -> R
): R
Shouldn't reduce
be able to take two independent types instead? Something like
inline fun <S, T> Array<out T>.reduce(
operation: (acc: S, T) -> S
): S
For context, I am trying to use reduce
with a long
accumulator and a domain object I am using. Something like:
myCollection.reduce { acc, myObject ->
acc + myObject.myField
}
That doesn't work but this does:
myCollection.fold(0) { acc, myObject ->
acc + myObject.myField
}
This is counterintuitive and confusing.nickheitz
11/05/2020, 11:47 AMval deviceMap = mutableMapOf(
"organisationId" to authenticationData.organisationId,
"userId" to authenticationData.userId,
"deviceTemplateUuid" to AuthenticationService.DeviceTemplate.findById(authenticationData.deviceTemplateId).clientId,
"dateInstalled" to dateInstalled
).also {
it.putAll(extraProps)
}
The variable "extraProp" is defined as Map<String, Any>.
In the past, I'm certain kotlin would have interpreted the return from "mutableMapOf" as MutableMap<String, Any>, but now I'm suddenly getting the following compiler error:
Kotlin: Type mismatch: inferred type is Map<String, Any> but Map<out String, {Comparable<{Instant & String & UUID}> & java.io.Serializable}> was expected
Is it mandatory now that I give a type hint to the function as "mutableMapOf<String,Any>(...)" to avoid this Union type nightmare?Pacane
11/05/2020, 2:59 PMval a: String? = ...
val b: String? = ...
if (listOf(a,b).any { it == null }) {
return
}
val l = a.length // compiler complains here
Basically I'm doing null checks in for a bunch of variables before doing something with them. Shouldn't the compiler know about a
on the last line, not being null?Rob Elliot
11/05/2020, 4:02 PMfun <T> populate(i: Int, f: (Int) -> T): List<T> = (0 until i).map(f)
fun <T> populate(i: Int, t: T): List<T> = populate(i) { t }
populate(4, "Hello") == listOf("Hello", "Hello", "Hello", "Hello")
populate(4) { "Hello $it" } == listOf("Hello 0", "Hello 1", "Hello 2", "Hello 3")
Ryan
11/05/2020, 5:38 PMlaith
11/05/2020, 9:13 PMjeggy
11/05/2020, 10:31 PMtoString
function on data classes? Can be with annotation or anything. I want to achieve something like this: https://pl.kotl.in/Ld0EBnHM1mplain
11/06/2020, 11:23 AMStragaSevera
11/06/2020, 5:36 PMclass MyDelegatedProperty {
var innerStr: String = ""
operator fun getValue(thisRef: Any, property: KProperty<*>): String {
return innerStr
}
operator fun setValue(thisRef: Any, property: KProperty<*>, value: String) {
innerStr = value
}
fun doSomething() {
println(innerStr)
}
}
class Example {
val str: String by MyDelegatedProperty()
fun main() {
// use the doSomething function from str
}
}
Is this possible somehow? Can I access the object that is created by a delegated property?Mark Buikema
11/06/2020, 9:23 PMmapOf()
is not sorted
• sortedMapOf()
is mutable
• hashMapOf()
is mutable and not sorted
• linkedMapOf()
is mutable
Any other suggestions?ArcticLampyrid
11/07/2020, 2:56 PMkotlin-serialization
, but I failed to test the modified one in local. How can I use a local modified one when building?william
11/07/2020, 10:39 PMbuild.gradle
?Animesh Sahu
11/08/2020, 11:02 AMDeactivated User
11/08/2020, 12:37 PMTrevor Ackerman
11/08/2020, 2:19 PMFlorian
11/08/2020, 6:28 PMPreferencesKey.
prefix?
private object PreferencesKeys {
val SORT_ORDER = preferencesKey<String>("sort_order")
val HIDE_COMPLETED = preferencesKey<Boolean>("hide_completed")
}
Alec Muffett
11/08/2020, 10:38 PM[INFO] --- kotlin-maven-plugin:1.4.20-RC:compile (compile) @ app ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/Users/alecm/.m2/repository/org/jetbrains/kotlin/kotlin-compiler/1.4.20-RC/kotlin-compiler-1.4.20-RC.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
V Badalyan
11/09/2020, 1:03 AMdata claaa D(vtype: string, value: int, dim1 ... dimX)
где dimX - некоторые "классификации, дайменшены)
Собственно я беру этот CSV - прогоняю через скажем 5 фильтров и остается у меня от общем массы по 1% в каждом из этих 5 флоу.
Вопрос. Как эффективно также продолжая 1 проход отфильровать из 5 отдельных фору группу где di1 и dim2 и dim3 у элементов совпадают). Те сделать группировку по разрезу и отсеять где нет полного совпадения....
Завис Пока только смог сделать промежуточную фильтрацию "Явно не войдет" и дальше второй проход уже по (флоу в буфер/канал) каналам в который результат первого цикла. Есть идеи? Как можно не дожидаясь окончание потока получить на текущем результате пересечение и сразу же по нему отдельный поток/корутин .nbaztec
11/09/2020, 8:54 AMcheck
functions? We have a use-case where we'd like to throw a concrete custom Exception. What would be the ideal way to do it?
Wrap it later, but use check
try {
check(<exp>){ "check failed"}
} catch(e: IllegalStateException) {
throw CustomException(e)
}
or throw it directly,
if (<exp>) {
throw CustomException("check failed)
}
CLOVIS
11/09/2020, 11:14 AMMatej Drobnič
11/09/2020, 11:35 AMString
* in T
means that I can pass T or any of its super classes
* Any
is superclass of String
* so Container<in T>
should accept Container<Any>
right?
Instead I get:
Type mismatch.
Required :String
Found: Any
Matej Drobnič
11/09/2020, 11:52 AMT
is String
* out T
means that String or any of its subtypes can fit this
* Since String
in methodB
matches that, why I can't pass methodB
into methodA
?Florian
11/09/2020, 6:07 PMinline fun SearchView.onQueryTextChanged(crossinline listener: (String) -> Unit) {
this.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
return true
}
override fun onQueryTextChange(newText: String?): Boolean {
listener(newText.orEmpty())
return true
}
})
}
Do I understand that correctly, the crossinline
modifier assures that we can't call return in the lambda we are passing to this function? Because if we don't call return
here, we would leave the onQueryTextChange
method.diesieben07
11/09/2020, 9:07 PMdf
11/09/2020, 10:06 PMIfvwm
11/10/2020, 2:26 AM