Programming Kotlin Applications. Бретт Мак-Лахлин. Читать онлайн. Newlib. NEWLIB.NET

Автор: Бретт Мак-Лахлин
Издательство: John Wiley & Sons Limited
Серия:
Жанр произведения: Программы
Год издания: 0
isbn: 9781119696216
Скачать книгу
CLASSES REQUIRE SEVERAL THINGS FROM YOU DATA CLASSES ADD SPECIAL BEHAVIOR TO GENERATED CODE DATA CLASSES ARE BEST LEFT ALONE

      17  9 Enums and Sealed, More Specialty Classes STRINGS ARE TERRIBLE AS STATIC TYPE REPRESENTATIONS COMPANION OBJECTS ARE SINGLE INSTANCE ENUMS DEFINE CONSTANTS AND PROVIDE TYPE SAFETY SEALED CLASSES ARE TYPE-SAFE CLASS HIERARCHIES

      18  10 Functions and Functions and Functions REVISITING THE SYNTAX OF A FUNCTION FUNCTIONS FOLLOW FLEXIBLE RULES FUNCTIONS IN KOTLIN HAVE SCOPE FUNCTION LITERALS: LAMBDAS AND ANONYMOUS FUNCTIONS LOTS OF FUNCTIONS, LOTS OF ROOM FOR PROBLEMS

      19  11 Speaking Idiomatic Kotlin SCOPE FUNCTIONS PROVIDE CONTEXT TO CODE USE LET TO PROVIDE IMMEDIATE ACCESS TO AN INSTANCE WITH IS A SCOPE FUNCTION FOR PROCESSING AN INSTANCE RUN IS A CODE RUNNER AND SCOPE FUNCTION APPLY HAS A CONTEXT OBJECT BUT NO RETURN VALUE ALSO GIVES YOU AN INSTANCE … BUT OPERATES ON THE INSTANCE FIRST SCOPE FUNCTIONS SUMMARY

      20  12 Inheritance, One More Time, with Feeling ABSTRACT CLASSES REQUIRE A LATER IMPLEMENTATION INTERFACES DEFINE BEHAVIOR BUT HAVE NO BODY DELEGATION OFFERS ANOTHER OPTION FOR EXTENDING BEHAVIOR INHERITANCE REQUIRES FORETHOUGHT AND AFTERTHOUGHT

      21  13 Kotlin: The Next Step PROGRAMMING KOTLIN FOR ANDROID KOTLIN AND JAVA ARE GREAT COMPANIONS WHEN KOTLIN QUESTIONS STILL EXIST NOW WHAT?

      22  INDEX

      23  END USER LICENSE AGREEMENT

      List of Tables

      1 Chapter 2TABLE 2.1: Kotlin Types for Integers (Nondecimal Numbers)TABLE 2.2: Kotlin Types for Decimal Numbers

      2 Chapter 6TABLE 6.1: Differences between Covariant and Contravariant

      3 Chapter 11TABLE 11.1: Differences between scope functions

      List of Illustrations

      1 Chapter 1FIGURE 1.1 Download IntelliJ from the JetBrains download page.FIGURE 1.2 IntelliJ comes prepackaged with a system-specific installation pr...FIGURE 1.3 You'll generally be either creating a project from scratch or imp...FIGURE 1.4 IntelliJ makes getting going in Kotlin simple and prompts you on ...FIGURE 1.5 Kotlin code should go in the src/ folder.FIGURE 1.6 IntelliJ automatically formats code and adds sensible syntax high...FIGURE 1.7 You can click the green Run button and select the first option to...FIGURE 1.8 The empty output of your program (which will soon be non-empty) d...FIGURE 1.9 Good IDEs help you quickly find and fix errors.FIGURE 1.10 Why doesn't this override of toString() work?

      2 Chapter 2FIGURE 2.1 Your IDE should let you easily get to your source code as well as...FIGURE 2.2 Moving a class to a new package is basically a refactoring, which...FIGURE 2.3 Person is now nested under its containing package.FIGURE 2.4 IDEs will help you keep constructor properties straight.

      3 Chapter 4FIGURE 4.1 Code from Person expanded completelyFIGURE 4.2 You can collapse code blocks to the { … } form in your IDEFIGURE 4.3 Toggle between expanded and collapsed with the + and – icons

      4 Chapter 5FIGURE 5.1 Collection and several related classes

      5 Chapter 7FIGURE 7.1 An if statement adjusts how your code is executed and the flow of...FIGURE 7.2 Program execution has two different flows in this example.

      6 Chapter 10FIGURE 10.1 A function always has the same basic parts.FIGURE 10.2 A good IDE gives you default values for a function, even from a ...FIGURE 10.3 IDEs help with arguments, especially if you're naming arguments ...FIGURE 10.4 An unused anonymous functionFIGURE 10.5 A function assigned to a variable is treated like the function i...

      7 Chapter 11FIGURE 11.1 Good IDEs warn you of conflicts in scope function variables.FIGURE 11.2 Distinguishing between a String and a String?FIGURE 11.3 An IDE helping with the this reference in a with expressionFIGURE 11.4 Kotlin suggests using run to both initialize an instance and get...FIGURE 11.5 The also function provides an it reference to the context object...

      8 Chapter 12FIGURE 12.1 An inheritance hierarchy using interfaces, abstract classes, and...FIGURE 12.2 The go() function in Vehicle eventually is handled by drive() im...

      9 Chapter 13FIGURE 13.1 Kotlin's reference documentation is thorough and helpful.FIGURE 13.2 The Kotlin Koans aren't for everyone, but they're great for inte...