Читать книгу Programming Kotlin Applications - Бретт Мак-Лахлин, Brett McLaughlin - Страница 53
LISTING 2.2: Main function for testing the Person class
Оглавлениеfun main() { // Create a new person val brian = Person("Brian", "Truesby") println(brian) // Create another person val rose = Person("Rose", "Bushnell") println(rose) // Change Rose's last name rose.lastName = "Bushnell-Truesby" println(rose) }
At this point, you should be able to run PersonApp
just as you did in Chapter 1. Your output should also be the same. You can see in Figure 2.1 the IntelliJ IDE, with the two Kotlin files as tabs, and the output in the bottom pane.
FIGURE 2.1 Your IDE should let you easily get to your source code as well as see output.
WARNING If you get any warnings, the most likely culprit is that you didn't create your Person
and PersonApp
files in the same directory. Make sure both files are in the src/
directory and try again.
At this point, you could go ahead and keep creating more objects in the src/
directory. But there's still a better way!