Book Sample

Please Note: This sample is under development and the formatting and structure are subject to change.

(The coverage of the sample—sections I and II—will remain the same).

Table of Contents

How to Use This Book

Viewing the eBook

Introduction

Examples & Exercises

Section I: Programming Basics

Hello, World!

var & val

Data Types

Functions

If Expressions

String Templates

Number Types

Booleans

Repetition with while

Looping & Ranges

The in Keyword

Expressions & Statements

Summary 1

Section II: Introduction to Objects

Objects Everywhere

Creating Classes

Properties

Constructors

Constraining Visibility

Imports & Packages

Testing

Exceptions

Lists

vararg Arguments

Sets

Maps

Property Accessors

Summary 2

Section III: Usability

Extension Functions

Named & Default Arguments

Overloading

when Expressions

Enumerations

Data Classes

Nullable Types

Safe Calls & The Elvis Operator

Non-null Assertions

Extensions for Nullable Types

Introduction to Generics

Extension Properties

Section IV: Functional Programming

Lambdas

The Importance of Lambdas

Operations on Collections

Member References

Function Types

Manipulating Lists

From Lists to Maps

Lambda with Receiver

The with() Function

Library Helpers

Sequences

More Library Functions

Functions Inside Functions

Folding Lists

Recursion

Section V: Object-Oriented Programming

Interfaces

Non-trivial Constructors

Inheritance

Base Class Initialization

Abstract Classes vs Interfaces

Polymorphism

Composition

Companion Objects

Objects

Class Delegation

Sealed Classes

Smart Casts

Section VI: Power Tools

Generics

Immutability

Hashing

Operator Overloading

Using Operators

Destructuring Declarations

Property Delegation

Lazy Initialization

Property Delegation Tools

Late Initialization

Exception Handling

Error Reporting

Logging

Unit Testing

Type Parameter Constraints

Reflection

Domain-Specific Languages

Coroutines

Section VII: Language Interoperability

Calling Java from Kotlin

Calling Kotlin from Java

Collections & Java

Nullable Types & Java

Nullability Annotations

Appendix A: Resources

Appendix B: AtomicTest