Hello, I have `infix fun A.function(b): X` , then...
# announcements
d
Hello, I have
infix fun A.function(b): X
, then I have
operator fun X.invoke(f: () -> Unit)
so I’m trying to call
a function b { ... }
But I get B cannot get invoked as a function, I’ve tried to use
plus
a function b +{ ... }
But I got something similar. If it use infix
infix operator fun X.invoke(f: () -> Unit)
is fine (
a function b invoke { ... }
), but cannot get rid of that explicit
invoke
If I do like
(a function b) { ... }
is also fine, but still ugly 🙂 Any solution? Thanks 🙂
Ye, but that’s very ugly and make very little sense that:
a func b run { ... }
OK
a func b + { ... }
NO 😕
s
i wonder what a PEMDAS-style mnemonic for Kotlin order of operations would look like 😛
d
Ok, talking about math operators it sounds different, the
+
was just a try that could be nice, it’s not supposed to be a math stuff. But why
a func b plus { ... }
is fine?
Ok, perhaps I got it 🙂
Yup, got it. Thank you 🙂 I’ll try to declare the plus operator on
B
and handle like:
A.func(BPlus)
I might get out if it 🙂
Kinda like it 🙂 Thank you again