forecastList.adapter = ForecastListAdapter(items)
16
}
List creation
Though I’ll talk about collections later on this book, I just want to explain for now that you
can create constant lists (what we will see as immutable soon) by using the helper function
listOf
. It receives a
vararg
of items of any type and infers the type of the result.
There are many other alternative functions, such as
setOf
,
mutableListOf
or
hashSetOf
among others.
I also moved some classes to new packages, in order to improve organisation.
We reviewed many new ideas in such a small amount of code, so I’ll be covering them in the next
chapter. We can’t continue until we learn some important concepts regarding basic types, variables
and properties.
Do'stlaringiz bilan baham: |