Читать книгу Programming Kotlin Applications - Бретт Мак-Лахлин, Brett McLaughlin - Страница 45

Kotlin Auto-Generates Getters and Setters

Оглавление

At this point, things are going well. Part of that is all you've added, but another big help is that Kotlin is doing a lot behind the scenes. It's running code for you automatically (like that initializer block) and letting you override methods.

It's doing something else, too: it's auto-generating some extra methods on your class. Because you made firstName and lastName property values (with that val keyword), and you defined a fullName property, Kotlin created getters and setters for all of those properties.

Programming Kotlin Applications

Подняться наверх