Daniele B
01/12/2021, 1:37 PMDmitry
01/12/2021, 1:39 PMDaniele B
01/12/2021, 1:43 PMDaniele B
01/12/2021, 1:43 PMDaniele B
01/12/2021, 1:46 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?Dmitry
01/12/2021, 1:56 PMList
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 PMDaniele B
01/12/2021, 2:06 PMDaniele B
01/12/2021, 2:07 PMDaniele B
01/12/2021, 2:08 PMDaniele B
01/12/2021, 2:09 PMDmitry
01/12/2021, 2:19 PMthis
.Daniele B
01/12/2021, 2:20 PMDaniele B
01/12/2021, 2:22 PMDmitry
01/12/2021, 2:24 PMDaniele B
01/12/2021, 2:26 PMDaniele B
01/12/2021, 2:27 PMDaniele B
01/12/2021, 2:28 PM