droidrcc
01/26/2018, 5:40 PMstephan_marshay
01/26/2018, 8:46 PMjoelpedraza
01/26/2018, 8:58 PMHassan
01/26/2018, 10:53 PMedik
01/26/2018, 11:56 PMclass Jikaz {
var id: Int? = null
init {
id = nextId?.inc()
}
companion object {
var nextId : Int? = 1
}
}
fun main(args: Array<String>) {
Jikaz()
Jikaz()
println("result z =${Jikaz().id!!}")
}
edik
01/27/2018, 12:13 AMedik
01/27/2018, 12:57 AMedik
01/27/2018, 1:08 AMrichardfinegan
01/27/2018, 6:04 PMzake
01/28/2018, 6:14 AMclass Foo {
val bar = mutableListOf<Bar>()
get() {
return listOf(*bar.toTypedArray())
}
}
?
It would seem that the only way is to really just do
val bar = mutableListOf<Bar>()
...
fun getBar(): List<Bar> = bar
, but the result is that it you get two getters with the same signature on the JVM
Update:
If you just add the @JvmField
decorator, you don’t have to deal with that, but is there a way to do it as closely to the top idea? Because you can still just get the mutableList as a property apparently
Update:
Backing the field is probably the solution.benleggiero
01/28/2018, 7:14 AMimport packageWithWayTooMuchInside.*
?raulraja
01/29/2018, 1:42 AMvar occupant: T
happens in invariant position and you are stating that crate: Crate<in Dog>
is contravariant. If you change crate: Crate<in Dog>
to crate: Crate<out Dog>
or just crate: Crate<Dog>
it will compile.
I'm guessing star projections are equivalent to existential types and unaffected by variance and Animal
is all it can infer there based on your T : Animal
constrain.davidase
01/29/2018, 11:00 AMSnowmanX95
01/29/2018, 5:02 PMilya.gorbunov
01/29/2018, 9:26 PMevent
with true
and that results in else block being executedsnowe
01/29/2018, 9:27 PMShawn
01/29/2018, 9:31 PMpakoito
01/30/2018, 12:22 AMpakoito
01/30/2018, 12:22 AMGizmo
01/30/2018, 1:08 PMilya.gorbunov
01/30/2018, 1:56 PM(String) -> Any
dave08
01/30/2018, 6:01 PMLeeeloo Minai
01/30/2018, 8:10 PMLeeeloo Minai
01/30/2018, 8:21 PMOlekss
01/30/2018, 8:25 PMalex2069
01/30/2018, 11:45 PMvitrox1
01/31/2018, 9:05 AMpniederw
01/31/2018, 11:31 AMLucas Ribeiro
01/31/2018, 12:30 PM@Json
annotation, if you remove the annotation and name the variable with the name that you receive on json, it's work ?north
01/31/2018, 1:08 PMdata class XData(val one: Int)
abstract class MyBinder : Binding<Any, List<XData>>
Here is the bytecode genrated for it:
// declaration: MyBinder implements Binding<java.lang.Object, java.util.List<? extends XData>>
is there any way to enforce the type to be Binding<java.lang.Object, java.util.List<XData>>
instead of Binding<java.lang.Object, java.util.List<? extends XData>>
north
01/31/2018, 1:08 PMdata class XData(val one: Int)
abstract class MyBinder : Binding<Any, List<XData>>
Here is the bytecode genrated for it:
// declaration: MyBinder implements Binding<java.lang.Object, java.util.List<? extends XData>>
is there any way to enforce the type to be Binding<java.lang.Object, java.util.List<XData>>
instead of Binding<java.lang.Object, java.util.List<? extends XData>>
diesieben07
01/31/2018, 1:10 PM@JvmSuppressWildcards
annotation does what you want.north
01/31/2018, 1:11 PM