Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // try to add item and tell it's projected as <out Any?>
  2. // show it's possible using type parameter also
  3. fun printItems(items: MutableList<*>) {
  4. for(i in items.indices){
  5. println(items.get(i))
  6. }
  7. }
  8.  
  9. fun main(){
  10. val x: MutableList<Any> = mutableListOf(1,2,"a")
  11. printItems(x)
  12.  
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement