dragas
04/07/2017, 12:12 PMlazy
and {
have to be on the same line?user
04/07/2017, 12:55 PMcedric
04/07/2017, 2:52 PMkyonifer
04/07/2017, 2:52 PMchristophsturm
04/07/2017, 3:05 PMbjartek
04/07/2017, 7:45 PMsreich
04/07/2017, 9:24 PMDalinar
04/09/2017, 2:38 AMqux.getClass().equals(Foo.class)
, was just wondering if there was a simpler way in Kotlin - i guess something like qux.javaClass === Foo::javaClass
is the shortest it can be - but I'm confused if it should be ===
or ==
. I guess from the java code, it should be ==
(update: nope, that doesn't work - see reply thread)bombe
04/09/2017, 2:05 PMmiha-x64
04/09/2017, 5:43 PMclass Something<X : Serializable>
.
In Java, within a class with unbound T
type parameter, public void do(Something<T> something)
is an error (since only Something<T & Serializable>
can exist in this context), but Something<? extends T>
is OK. In Kotlin, both Something<T>
and Something<out T>
are errors. Is it by Kotlin design? Or a Java bug? 🙃dimsuz
04/10/2017, 9:51 AMOutdated Kotlin Runtime
Your version of Kotlin runtime in 'kotlin-runtime-1.0.2' library is 1.0.2, while plugin version is 1.1.1-release-Studio2.3-1.
I checked all my gradle dependencies - no 1.0.2
there, 1.1.1
in all places. My project is also using features of 1.1.1
and compiles fine. How do I track down what causes this warning?mikehearn
04/11/2017, 1:47 PMjaguililla
04/11/2017, 2:47 PMnimtiazm
04/12/2017, 6:42 AM{ it -> it }
vach
04/12/2017, 10:59 AMclass MutableLazy<T>(val supplier : ()-> T) {
private val mutableOption = MutableOption.empty<T>()
fun getValue() = mutableOption.ifNotPresentCompute(supplier).get()
fun setValue(value : T) = mutableOption.take(value)
fun isInitialized() = mutableOption.isPresent
}
inline operator fun <T> MutableLazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = getValue()
inline operator fun <T> MutableLazy<T>.setValue(thisRef: Any?, property: KProperty<*>, t: T) {
setValue(t)
}
var something : String by MutableLazy {
log("computing this value")
"default value"
}
fun main(args: Array<String>) {
something = "manually set value" // comment/uncomment this line...
println(something)
}
Consider mutable option just like normal option except not immutable... I can simply replace it with any synchronized wrapper of single generic value...rrva
04/12/2017, 12:07 PMpublic <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
aballano
04/12/2017, 1:25 PMlouiscad
04/12/2017, 2:29 PMlazy
implementations all extend Serializable
?kenkyee
04/12/2017, 5:10 PMkastork
04/12/2017, 5:13 PMjkbbwr
04/12/2017, 6:15 PMmarcinmoskala
04/12/2017, 10:34 PMfun <T> mutableLazy(initializer: () -> T): ReadWriteProperty<Any?, T> = MutableLazy<T>(initializer)
private class MutableLazy<T>(val initializer : ()-> T): ReadWriteProperty<Any?, T> {
private var value: T? = null
private var initialized = false
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
if(!initialized) {
value = initializer()
}
return value as T
}
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
this.value = value
initialized = true
}
}
sreich
04/13/2017, 12:37 PMilya.gorbunov
04/13/2017, 3:03 PMkevinmost
04/13/2017, 4:49 PM+
(so org.jetbrains.kotlin:kotlin-gradle-plugin:+
), it'll get the latest version for you, and then Android Studio/IntelliJ will give you a warning + hotfix to change it to hardcode in the latest version. There are lots of articles detailing why actually using +
is not recommended, but using it to quickly sync + replace it with the actual latest version is good IMOsreich
04/13/2017, 6:21 PMjean
04/14/2017, 9:20 AMmiha-x64
04/14/2017, 11:48 AMjw
04/15/2017, 3:25 AMB<Bar>
or B<String>
ilya.gorbunov
04/16/2017, 2:12 AMthis
inside it.
You can try to make it an extension function instead, so that this
becomes a plain parameter.ilya.gorbunov
04/16/2017, 2:12 AMthis
inside it.
You can try to make it an extension function instead, so that this
becomes a plain parameter.raulraja
04/16/2017, 5:04 PM