Kotlin Properties
In Kotlin, you can access properties of objects directly, using the object.property syntax, without the need for an access method (getters and setters in Java). You can see this in action in many places throughout the ContactsActivity class:
- In the
setupRecyclerView()method, therecyclerView.setAdapter(mAdapter)method is replaced withrecyclerView.adapter = mAdapterandviewHolder.getPosition()withviewHolder.position. - The EditText
setText()and,getText()methods are replaced throughout with the text property. ThesetEnabled()method is replaced with theisEnabledproperty. - The size of the
mContactslist is accessed withmContacts.sizethroughout. - You can access one of the items in the
mContactslist usingmContacts[index]instead ofmContacts.get(index).