elect
10/01/2021, 11:04 AMinterface WebhookEventInterface<T> {
operator fun invoke(block: WebhookEventInterface<T>.() -> Unit) {..}
}
in this way
interface PushPullRequestFeatures<T> : WebhookEventInterface<T> {
override operator fun invoke(block: PushPullRequestFeatures<T>.() -> Unit) {..}
}
Unfortunately I didn't find a way to successfully infer the new receiver on the lambda.
The above code does not override the super method:
'invoke' overrides nothingand there is also a platform clash:
Platform declaration clash: The following declarations have the same JVM signature (invoke(Lkyge/triggerEvents/PushPullRequestFeatures;Lkotlin/jvm/functions/Function1;)V):I've tried to use
@JvmName
, but it says:
I tried also'@JvmName' annotation is not applicable to this declaration
@OverloadResolutionByLambdaReturnType
by changing the return type, but the clash doesn't go away neither
Any idea?MarkRS
10/01/2021, 2:48 PMBrian Donovan
10/01/2021, 5:12 PMelect
10/02/2021, 10:40 AMval username by Input { }
Where
class Input {
companion object {
operator fun invoke(..): Input {
..
}
}
}
And
internal operator fun Any.getValue(thisRef: Any?, property: KProperty<*>): Input {
println("$thisRef, thank you for delegating '${property.name}' to me!")
val pInput = property as KProperty0<Input>
println(pInput)
return pInput.get()
}
pInput
is a valid KProperty0
class, but the moment I call .get()
to retrieve Input
, then I get:
java.lang.UnsupportedOperationException: call/callBy are not supported for this declaration.Why? How can I fix it? What is the way to retrieve the
Input
instance produced by its own companion object?Sohel Shaikh
10/02/2021, 12:06 PMAlex
10/02/2021, 5:46 PMinline fun <T, R> T.let(*block*: (T) -> R): R
1) <T, R> T what does the extra T outside the <> mean
2) What does R mean
Hullaballoonatic
10/02/2021, 9:55 PMelect
10/03/2021, 7:40 AMvar configure: Input.() -> Unit
as a property on Input
itself in order to execute it later on.
However, to execute it externally, I have to call input.configure(input)
... does this sound right?
I'm inclined to think so, because if I scope input
, then I can simply call configure as input.apply { configure() }
, but I'd like to have some feedbacks on thislhwdev
10/04/2021, 5:00 AMfun <T> test(value: T): T {
value as Int
return 123
}
Shouldn't this work?ursus
10/04/2021, 11:19 AMlateinit var .... ::viewModel.isInitialized
what is this at runtime? should I be vary of calling it too frequently? or is it just null check and assert?Chris Fillmore
10/04/2021, 2:19 PMSet
compared via equals()
?Ayfri
10/04/2021, 8:49 PMinfix
functions are useful ?Jonathan Hollingsworth
10/05/2021, 1:16 AMdefaultValue
, but the type of that value is dependent on dataType
property. I was thinking I’d need a union type for defaultValue
, but just found out Kotlin doesn’t support that.
I could use Any
, but that breaks the kotlinx.serialization @Serialiazable
annotation.
Has anyone got any ideas or can point me in the right direction?Ahmed
10/05/2021, 7:13 AMunit-Test-coverage
written in kotlin with spring boot 2Daniel Svensson
10/05/2021, 11:35 AMvalue class WriteableResource(val ro: Resource)
to a method only accepting Resource
without explicitly passing its member? Does it have to explicitly implement an interface for Resource
?carbaj0
10/06/2021, 9:29 AMdata class
with parentheses?dave08
10/06/2021, 1:35 PMval l = listOf(foo1, foo2, foo3)
var found = l.find(::criteria1)
if (found != null) return doAction(found)
var found = l.find(::criteria2)
if (found != null) return doAction2(found)
...
Jonathan Hollingsworth
10/07/2021, 3:28 AMval components: List<Component> = BuilderClass(...some stuff...).into(Component)
I.e. you use the into
function to take any Class and return a list of that class
Something like
Class BuilderClass(...) {
fun into(klass: KClass<Any>): List<what_goes_here?> {
...
Anyone know if this is possible?Slackbot
10/07/2021, 9:49 AMMichael de Kaste
10/07/2021, 1:51 PMdave08
10/07/2021, 3:52 PMinterface Foo {
fun printlog(msg: String) = "... - $msg"
}
class Bar : Foo
How can I get the printlog in the interface to print out Bar - some message
? If I use ${this::class.simpleName}
it just gives me the interface's name...Tianyu Zhu
10/07/2021, 4:03 PMLuffy D. Monkey
10/07/2021, 4:33 PM:kotlin-stdlib:commonSources
fails with
No compatible toolchains found for request filter: {languageVersion=6, vendor=any, implementation=vendor-specific} (auto-detect true, auto-download true)
I am currently on macOS and have installed java6 using brew as mentioned in the README. How to resolve this issue?Jonathan Hollingsworth
10/07/2021, 6:29 PMMyClass(**mutableMapObj)
I’ve tried various options using kclass and callBy, but what I really want to do is destructure the mutableMapObj into the class instantiation call.
I.e. my MyClass.pleaseTakeAMap(mutableMapObj)
is equivalent to MyClass(param1 = mutableMapObj["param1"], param2 = mutableMapObj["param2"]
Ideally I could do this without have to add to companion object onto each data class.Alejo
10/07/2021, 6:31 PMmaxOf("aaaa","zzz")
and return "aaaa"
. How could I achieve this?David Lax
10/08/2021, 12:04 AMpublic final func<R> change(method: (I) -> R): Mono<R> { .... }
and I want to mock this function for any input I want to return a Mono.Empty response. How do I do it? I am lost. I am using MockitoGilles Barbier
10/08/2021, 8:29 AMCoffee Guy
10/08/2021, 5:41 PMIbrahimAbousalem
10/10/2021, 7:05 PMsealed class States{
object Loading:States()
data Success(val data: String):States()
}
results.filter{
it.state is States.Success
}.forEach{ successState ->
println(successState.data) //Error since this still State not Success State
}
David Lax
10/11/2021, 2:31 AMDavid Lax
10/11/2021, 2:31 AMJacob
10/11/2021, 3:47 AMGrégory Lureau
10/11/2021, 7:30 AM()->String
can become UserIdProvider
, UuidGenerator
...). Maybe another workaround for your issue?