Kotlin Essentials:

Kotlin is a powerful language, largely thanks to its expressive syntax, intuitive and null-safe type system, and great tooling support. It’s no wonder that Kotlin is the most popular language for Android development and is a popular replacement for Java on backend applications. It is also used for data science and for multiplatform, iOS, desktop, and web application development.
This book covers the essentials of Kotlin so you can start developing with this amazing programming language. It shows nearly everything you need to know in clear and executable code examples.
The purpose

Chapter by Chapter
Clear path to progress
1.Introduction
- Who is this book for?
- What will be covered?
- The Kotlin for Developers series
- My story
- Conventions
- Code conventions
- Exercises and solutions
- Acknowledgments
2.What is Kotlin?
- Kotlin platforms
- The Kotlin IDE
- Where do we use Kotlin?
3.Your first program in Kotlin
- Live templates
- What is under the hood on JVM?
- Packages and importing
- Summary
- Exercise: Your first program
4.Variables
5.Basic types, their literals and operations
- Numbers
- Booleans
- Characters
- Strings
- Summary
- Exercise: Basic values operations
6.Conditional statements
- if-statement
- when-statement
- when-statement with a value
- is check
- Explicit casting
- Smart-casting
- While and do-while statements
- Summary
- Exercise: Using when
- Exercise: Pretty time display
7.Functions
- Single-expression functions
- Functions on all levels
- Parameters and arguments
- Unit return type
- Vararg parameters
- Named parameter syntax and default arguments
- Function overloading
- Infix syntax
- Function formatting
- Summary
- Exercise: Person details display
8.The power of the for-loop
- Ranges
- Break and continue
- Use cases
- Summary
- Exercise: Range Operations
9.Nullability
- Safe calls
- Not-null assertion
- Smart-casting
- The Elvis operator
- Extensions on nullable types
- null is our friend
- lateinit
- Summary
- Exercise: User Information Processor
10.Classes
- Member functions
- Properties
- Constructors
- Classes representing data in Kotlin and Java
- Inner classes
- Summary
- Exercise: Implementing the Product class
11.Inheritance
- Overriding elements
- Parents with non-empty constructors
- Super call
- Abstract class
- Interfaces
- Visibility
- Any
- Summary
- Exercise: GUI View Hierarchy Simulation
12.Data classes
- Transforming to a string
- Objects equality
- Hash code
- Copying objects
- Destructuring
- When and how should we use destructuring?
- Data class limitations
- Prefer data classes instead of tuples
- Summary
- Exercise: Data class practice
13.Objects
- Object expressions
- Object declaration
- Companion objects
- Data object declarations
- Constant values
- Summary
- Exercise: Pizza factory
14.Exceptions
- Throwing exceptions
- Defining exceptions
- Catching exceptions
- A try-catch block used as an expression
- The finally block
- Important exceptions
- The hierarchy of exceptions
- Summary
- Exercise: Catching exceptions
15.Enum classes
- Data in enum values
- Enum classes with custom methods
- Summary
- Exercise: Days of the week enum
16.Sealed classes and interfaces
- Sealed classes and when expressions
- Sealed vs enum
- Use cases
- Summary
17.Annotation classes
- Meta-annotations
- Annotating the primary constructor
- List literals
- Summary
18.Extensions
- Extension functions under the hood
- Extension properties
- Extensions vs members
- Extension functions on object declarations
- Member extension functions
- Use cases
- Summary
- Exercise: Conversion and measurement unit creation
19.Collections
- The hierarchy of interfaces
- Mutable vs read-only types
- Creating collections
- Lists
- Sets
- Maps
- Using arrays in practice
- Summary
- Exercise: Inventory management
20.Operator overloading
- An example of operator overloading
- Arithmetic operators
- The in operator
- The iterator operator
- The equality and inequality operators
- Comparison operators
- The indexed access operator
- Augmented assignments
- Unary prefix operators
- Increment and decrement
- The invoke operator
- Precedence
- Summary
- Exercise: Money operations
21.The beauty of Kotlin’s type system
- What is a type?
- Why do we have types?
- The relation between classes and types
- Class vs type in practice
- The relationship between types
- The subtype of all the types: Nothing
- The result type from return and throw
- When is some code not reachable?
- The type of null
- Summary
- Exercise: The closest supertype of types
22.Generics
- Generic functions
- Generic classes
- Generic classes and nullability
- Generic interfaces
- Type parameters and inheritance
- Type erasure
- Generic constraints
- Star projection
- Underscore operator for type arguments
- Summary
- Exercise: Stock
23.Final words
- Final Project: Workout manager
24.Exercise solutions
25.Notes