Stephan Schroeder
02/14/2020, 5:03 PMFun String.removeChars(allTheCharsToRemove: String): String
there is the String.replace(regex, replacement) that you could call with ""
as second parameter. So I’d have to create a Regex from my allTheCharsToRemove
(how? if that’d be your approach) or is there a better way?Luke
02/14/2020, 6:41 PMinline fun <T> List<T>.applyOnEach(block: T.() -> Unit): List<T> = onEach { it?.block() }
Is there a way to mark the receiver in T.() -> Unit
as not nullable?Buzz
02/14/2020, 10:15 PMBrian Dilley
02/14/2020, 11:54 PMBruno_
02/15/2020, 3:07 PMbod
02/15/2020, 5:37 PMDuration
abstraction but what about a Moment (aka, Date or Time stamp, or a point in time)? Is that what ClockMark
represents?ec
02/15/2020, 8:32 PMtypealias SessionId = String
typealias TopicName = String
fun unsubscribe(who: SessionId, from: TopicName) {..}
fun subscribe(to: TopicName, handler: (Topic) -> Unit)
Jeff
02/16/2020, 9:48 AMChills
02/16/2020, 1:58 PMco-routine scopes
for coroutines
can someone explain me in layman
terms.
builders are used to create coroutines
dispatchers to alter context.camkadev
02/16/2020, 3:11 PMCannot infer type parameter
what should i do at Serializer
line 31
?
https://github.com/AlexanderShniperson/KotlinNativeSerializationkrtko
02/16/2020, 9:08 PMany::class.simpleName
, does that still require including the Kotlin Reflection jar?ersin_ertan
02/17/2020, 12:42 AMpackage kotlin.reflect.jvm.internal.calls.Caller.checkArguments(args: Array<*>)
respect functions with default parameter values? I don't want to include it in func.call(..., "alreadyHasADefaultValue")
, and am stopped by throw IllegalArgumentException("Callable expects $arity arguments, but ${args.size} were provided.")
Gyuhyeon
02/17/2020, 9:17 AM.filter{req: ClientRequest, next: ExchangeFunction ->
// do something
}
works.
However, what I'd like to do is pass a function reference instead of the lambda so that I don't have to actually put 50 lines of code inside the .filter
call.
I'm quite new to Kotlin and I have a very fragile understanding of higher order functions, so I have no idea how to achieve this.
I thought making the method like this -
private fun customFilter(request: ClientRequest, next: ExchangeFunction){
}
and calling like .filter(::customFilter)
would work, but it didn't - IDE tells me
Type mismatch.
Required:
ExchangeFilterFunction
Found:
KFunction2<@ParameterName ClientRequest, @ParameterName ExchangeFunction, Unit>
It seems like I have to somehow implement the ExchangeFilterFunction.java which is a java @FunctionalInterface
...? Any advice is appreciatedJakub
02/17/2020, 10:15 AMdays.groupBy { it.date.year }.forEach { (year, daysOfYear) ->
daysOfYear.groupBy { it.date.month }.forEach { (month, daysOfMonth) ->
aysOfMonth.groupBy { it.date.weekNumber() }.forEach { (week, daysOfWeek) ->
}}}
2.
days.groupBy { Triple(it.date.year, it.date.month, it.date.weekNumber()) }.forEach { (triple, days) ->
}
hooliooo
02/17/2020, 12:48 PMChills
02/17/2020, 6:35 PMsuresh
02/18/2020, 5:20 AMOfir Bar
02/18/2020, 8:50 AMtjohnn
02/18/2020, 11:35 AM() -> Unit
eekboom
02/18/2020, 11:53 AMfun sort(list: List<String>): List<String> {
val collator = Collator.getInstance(Locale.GERMAN)
collator.strength = Collator.PRIMARY
return list.sortedWith(Comparator {a, b -> collator.compare(a, b)})
}
Gunslingor
02/18/2020, 2:40 PMJan Stoltman
02/18/2020, 3:20 PMEXPERIMENTAL_API_USAGE
warnings in my project build logmaxmello
02/18/2020, 4:25 PMabstract class A<T : A<T>>(
val id: Id<T>
)
class B(id: Id<B>) : A<B>(id)
class C(id: Id<C>) : A<C>(id)
I want to have polymorphism in a DB model, and the library provides type safe Id
with generics. I want the superclass to have the id property and to restrict it to be of any subclass of itself. For this I have the A<T : A<T>>
definition on top. Now, a subclass passes in its own type and only allows id to be of that type, making sure I never have Id<C>
in a B
class.
But when trying to use that type system, I have the problem of recursive definition of the parameter of A. For example when mapping a list of instances of objects holding subclasses of A, I need to specify the type variable like this:
SomeClassHoldingASubclasses(…)
=> SomeClassHoldingASubclasses<A<A<A ... > > >
It is not possible to do it like this: SomeClassHoldingASubclasses<*>
“projections are not allowed on type arguments of functions and properties”
If I remove the type variable from A, I cannot pass an id : Id<B> to the constructor of A.
I’m trying to get this to work for quite some time now, but are these polymorphic / self-referencing type variables even possible? Should I use in
or out
(I tried but that also went weird fast)?Ian
02/18/2020, 4:36 PMjava.lang.IllegalStateException: Backend Internal error: Exception during code generation
exception while trying to compile my code after updating some Gradle dependencies to their most recent version: https://gist.github.com/sanity/d4d0a84155a52a26c09386b0cf9a9e27
Anyone have any ideas what it might be? Unfortunately it's blocking progress on my project.Nikita Khlebushkin
02/18/2020, 5:15 PMopen fun track(event: String, properties: Map<Any?, *>?, options: Map<Any?, *>?): Unit
How can I create a map that would have satisfy properties
type?Jason
02/19/2020, 6:07 AMTransformations.map
and Livedata.map
?
Which one is better ? And what is usecase for it?camkadev
02/19/2020, 8:38 AMCarlosP
02/19/2020, 10:48 AMinterface ExperimentManagerDelegateCore {
interface ExperimentManagerDelegate:ExperimentManagerDelegateCore {
I have the classes:
abstract class ExperimentManagerCore {
open var delegate: WeakReference<out ExperimentManagerDelegateCore>? = null
}
class ExperimentManager():ExperimentManagerCore() {
override var delegate: WeakReference<ExperimentManagerDelegate>? = null
}
but in ExperimentManager
I got the error:
Type of 'delegate' doesn't match the type of the overridden var-property 'public open var delegate: WeakReference? defined in ExperimentManager.ExperimentManagerCore'
I thought I would fix it with out ExperimentManagerDelegateCore
Any ideas?Jan
02/19/2020, 12:20 PM0x1p10
in kotlin?Leon K
02/19/2020, 12:48 PMsuspend
, make the function suspend
, otherwise don't". I know the same thing can be achieved using inline fun
, but I have to access private fields in this function so that's not an optionLeon K
02/19/2020, 12:48 PMsuspend
, make the function suspend
, otherwise don't". I know the same thing can be achieved using inline fun
, but I have to access private fields in this function so that's not an optiondiesieben07
02/19/2020, 12:51 PMsuspend
(it has to take an additional Continuation
parameter)inline
and encapsulate the private access in a @PublishedApi internal fun
which does not suspend and doesn't use the lambda.Leon K
02/19/2020, 1:07 PMdiesieben07
02/19/2020, 1:10 PMLeon K
02/19/2020, 1:13 PMdiesieben07
02/19/2020, 1:17 PMLeon K
02/19/2020, 1:18 PMdiesieben07
02/19/2020, 1:21 PMprivate
(or in a private
class) then it can only ever be inline in the same class / file, so wherever it is inlined to also has access to the same private fields.private
fields are not part of your public API. If you could access them inside an inline
function they suddenly would be, because the code of your inline function gets copied into other people's code.Leon K
02/19/2020, 1:26 PM