Читать книгу Programming Kotlin Applications - Бретт Мак-Лахлин, Brett McLaughlin - Страница 64
Types Aren't Interchangeable (Part 2)
ОглавлениеFirst, take a look at PersonApp
, and specifically your main
function. Most IDEs will see that you've updated the constructor and give you some visual cues as to what properties you're currently passing into Person
. Note in Figure 2.4 that IntelliJ has identified the firstName
and lastName
properties being passed in so far.
FIGURE 2.4 IDEs will help you keep constructor properties straight.
Go ahead and make the changes to your function to pass in some values to fill out the new constructor for Person
. You'll need to add a height (I chose to use inches, but any unit of measurement works fine), an age, and whether the person has a partner. Listing 2.4 shows the result.