+ 2
Can anyone explain concept of in and out. In kotlin generic. Example code will help much better.
3 Antworten
+ 5
It is definitely a confusing concept. I have used it, but am by no means an expert. This link was how I managed to get it working. Given my hundreds of Kotlin codes, I haven't found where as yet.
https://blog.kotlin-academy.com/kotlin-generics-variance-modifiers-36b82c7caa39
+ 3
The out seems similar to wildcard in Java, but I've never made generics in Java so have never played with them. However, placing constraints on the types matches too and has similar syntax: <T : Number> would allow Int or Double types.
+ 2
Sir one more thing this in and out has any similarities with concept of wildcard extends and super upper bounded and lower bounded wild cards? In java.