Ben Madore
10/11/2019, 6:46 PMinternal fun getFoo(block: (Foo.() -> Unit)): Foo {
return Foo().apply{
//someinit
}.apply{
block()
}
…
}
right now if i don’t have actual functionality to include in the block i have to call it like: getFoo{}
is there a way to allow calling it like getFoo()
in this case?poohbar
10/11/2019, 6:46 PMinternal fun getFoo(block: (Foo.() -> Unit) = {}): Foo {
…
}
Ben Madore
10/11/2019, 6:48 PMMani
10/11/2019, 7:37 PMObject X {
fun foo() {
Y.A()
}
private fun bar() {}
Object Y {
fun A() {}
}
Object Z {}
}
Mani
10/11/2019, 7:38 PMbbaldino
10/11/2019, 9:12 PMclass Foo<T : Any>(private val valueType: KClass<T>) {
fun getThing(): T {
return when (valueType) {
// complains here: "Type mismatch, required T found Int" unless I add "as T" at the end
Integer.class -> functionThatReturnsInt()
Double.class, etc....
}
}
}
Hamza
10/12/2019, 12:28 AMimport kotlin.reflect.KProperty
object Items {
val x by SomeProperty("x")
val y by SomeProperty("y")
val z by SomeProperty("z")
}
fun main() {
println("a")
println(Items.x)
println("b")
}
class SomeProperty(val name: String) {
init {
println("Property $name was created")
}
operator fun getValue(ref: Any?, prop: KProperty<*>) = name
}
Hey guys, Is there a way to get around the fact that the properties are initialized lazily?Hamza
10/12/2019, 12:29 AMa
Property x was created
Property y was created
Property z was created
x
b
bmjav
10/12/2019, 2:55 PMAshutosh Panda
10/14/2019, 5:14 PMAshutosh Panda
10/14/2019, 5:16 PMJose Mauricio
10/14/2019, 5:53 PMstandinga
10/14/2019, 8:43 PMSteve Young
10/14/2019, 9:28 PMSiyamed
10/15/2019, 6:47 AMuser
10/15/2019, 3:00 PMveesus mikel heir
10/15/2019, 4:33 PMveesus mikel heir
10/15/2019, 4:33 PMclass Something : Base(){
override fun somethingMethod(param : String) : super(param){
// ...etc
}
}
veesus mikel heir
10/15/2019, 4:35 PMenighma
10/15/2019, 6:36 PMserebit
10/16/2019, 7:13 PMrocketraman
10/16/2019, 7:35 PMCaused by: java.lang.ClassCastException: class org.apache.pulsar.client.impl.BatchMessageIdImpl cannot be cast to class kotlin.Unit (org.apache.pulsar.client.impl.BatchMessageIdImpl and kotlin.Unit are in unnamed module of loader 'app')
at app.SomeConsumer$invoke$1.invokeSuspend(SomeConsumer.kt:40) ~[classes/:?]
... suppressed 5 lines
The line at SomeConsumer:40
is a suspending lambda that invokes a suspend function which returns nothing i.e. Unit
. The last line of that suspend function is actually a CompletableFuture.await()
suspending call that produces an org.apache.pulsar.client.impl.BatchMessageIdImpl
, but the function is defined to return Unit (and even if the last line of the function is changed to Unit
this still happens. Weird!Dmitri Sh
10/16/2019, 11:02 PMinterface Idea
. When in Swift, want to have a struct implement this interface, a.k.a now as protocol in the Swiftland. Get a compiler error - inheritance from non-protocol type 'IdeaModel'. In the generated objective-c file I see this - __attribute__((objc_subclassing_restricted)). Reading on it, all objective c protocols are restricted to classes. So how I do get around this problem?Animesh Sahu
10/17/2019, 3:01 AMgroostav
10/17/2019, 4:05 AMCloseable
.close()
not called style bugs. Unfortunately idiomatically using .use{}
or try-finally (or, RAII had i been on C++) is not possible, because these close()
calls relate to UI elements on binding logic.
There are some fairly simple assertions I can make. "Given a ui component X has a constructor annotated with @Inject
, and that constructor has members Y that themselves have a dispose()
method, then calling X.dispose()
should call Y.foreach { it.dispose() }
.
Anyone have ideas on how I might write a test-harness to let me quickly do that, instead of manually creating mocks and verifying behaviours etc?groostav
10/17/2019, 4:09 AM.use {}
?Ashutosh Panda
10/17/2019, 3:55 PMAshutosh Panda
10/17/2019, 3:55 PM