Artem
06/06/2018, 9:16 AMSmart cast to Type is impossible because propertyName is a mutable property that could have been changed by this time
. It relies on fact, that between checking for null and call to property value could have been changed by another thread. Proposed solution is to bake reference in a local variable and operate with it. It is great that developers of languages thought about situation of shared states between two threads, but it's really awkward to see this message in a program which operates in main thread only. Having to bake all properties seems really redundant in this scenario.
So my question is: is there any plan to introduce some way to mark property as thread safe? At least some annotation which will turn off this check?mdinino
06/06/2018, 2:56 PMhallvard
06/06/2018, 3:26 PMlazy
was doing it synchronized
? Isn't it supposed to be thread safe?wei
06/06/2018, 5:21 PMList<String>?
and I want to check that it contains at least one element. Is it possible to use just one condition check? I’ve tried:
val t: List<String>? = null
println(t?.size != 0)
and this prints true
, which is not what I want.
I tried: !t?.size?.equals(0)
but I can’t use this in an if
because it’s Boolean?
.Artem
06/06/2018, 5:23 PMfun doStuff(input:String) {
val split = input.split("foo", 0)
}
will not compile, but this one:
fun doStuff(input:String) {
val split = java.lang.String(input).split("foo", 0)
}
will be OK. Is it supposed behaviour (in other words, is it a bug or is it a feature)?Ruckus
06/06/2018, 9:31 PMclass Ref<K: Comparable<K>, T>(val key: K, val value: T) : Comparable<Ref<K, T>> {
override fun compareTo(other: Ref<K, T>) = key.compareTo(other.key)
}
fun main(args: Array<String>) {
val list = mutableListOf<Ref<Int, *>>()
list.sorted() // ERROR: Ref<Int, *> is not a subtype of Comparable<Ref<Int, *>>
}
Any ideas?Ruckus
06/06/2018, 9:33 PMsortedBy { it.key }
works. I'm trying to understand why *
doesn't)jw
06/06/2018, 9:50 PMjmccance
06/06/2018, 9:50 PMbdawg.io
06/06/2018, 10:07 PMghedeon
06/07/2018, 10:14 AMfoo
field is injected via DI, so it has to be lateinit. The thing is, this field is used to build another one — bar
. That's why the bar
is lazy.
@Inject
lateinit var foo
val bar by lazy { foo.foo() }
Now, I'm wondering if I can hide all this trickery behind some delegate or something, so I'll end up with a clean bar
initialization.
Ideal:
val bar by initBar() // somehow foo is injected inside?
Or at least:
@Inject
lateinit var foo
val bar by initBar(foo)
Andrei
06/07/2018, 10:51 AMabhijeetguptag
06/07/2018, 1:48 PMwouterdoeland
06/07/2018, 6:11 PMDataWatcherRegistry.b.a(7)
but there is a conflict because there are two functions named a
. One returns DataWatcherObject<T>
(the one I want) and another returns T
. How can I select the correct one, because right now, I'm getting some conflicts.jw
06/07/2018, 7:26 PMCall
is a representation of the pending request and its execution mechanism (which can either be synchronous or asynchronous). ResponseBody
is the body type, which in this case is a general wrapper around any HTTP response that will allow you to interpret it as bytes or a string or a stream.Dmitry
06/08/2018, 4:56 AMarekolek
06/08/2018, 6:44 AMgildor
06/08/2018, 6:44 AMSUPERCILEX
06/08/2018, 7:08 AMkokeroulis
06/08/2018, 2:25 PMkotlin_questions
06/08/2018, 4:54 PMikt
06/08/2018, 6:27 PMpurereborn
06/08/2018, 7:08 PMadam-mcneilly
06/08/2018, 7:12 PMikt
06/08/2018, 9:02 PMskennedy
06/08/2018, 9:44 PMReplaceWith
argument. alt-enter is simply deleting the line i’m on, rather than changing it to what’s specified in ReplaceWith
tipsy
06/09/2018, 9:35 AMrobstoll
06/09/2018, 1:24 PMahmed ali
06/10/2018, 11:02 AM