Daniele B
01/12/2021, 1:37 PMDmitry
01/12/2021, 1:39 PMDaniele B
01/12/2021, 1:43 PMDmitry
01/12/2021, 1:51 PMinternal
visibility means that your properties will be visible to everyone in your module.
Is that OK in your scenario?List
collection.
It has .get()
method to get element of a list.
To get last element of list you could write: list.get(list.size - 1)
.
So, you can achieve your goal using “core” API of a class.
But with extension function you can extract this code, to reuse is later as as list.last()
.
Your extension function in this case uses only public API (method get()
)Daniele B
01/12/2021, 2:05 PMDmitry
01/12/2021, 2:19 PMthis
.Daniele B
01/12/2021, 2:20 PMDmitry
01/12/2021, 2:24 PMDaniele B
01/12/2021, 2:26 PM