easyStudy question · answer published in Kotlin interview questions, so no pointskotlinkotlin-basics
Kotlin val with a mutable list
What does this Kotlin code print, and would the commented-out line compile if you removed the '//'?
val items = mutableListOf(1, 2) items.add(3) // items = mutableListOf(4) println(items)
Discussion 0
Join free to post in the discussion.
Related questions
- Kotlin Elvis operatorMobile App Developer
- Kotlin data class equalityMobile App Developer
- lateinit or by lazyMobile App Developer
- A chain of safe callsMobile App Developer
- What !! does on nullMobile App Developer
- What let returnsMobile App Developer
- Configuring an object with applyMobile App Developer
- object declarationMobile App Developer