Home Page Icon
Home Page
Table of Contents for
Programming Kotlin
Close
Programming Kotlin
by Venkat Subramaniam
Programming Kotlin
 Foreword
 Acknowledgments
 Introduction
Who Is This Book For?
What’s in This Book?
Kotlin and Java Versions Used in This Book
How to Read the Code Examples
Online Resources
1. Hello Kotlin
Reasons to Love Kotlin
Why Should You Choose Kotlin?
Taking Kotlin for a Ride
Compile to Bytecode and Run
Compiling to Other Targets
Which Option to Choose?
Wrapping Up
Part I. Scripting with Kotlin
2. Kotlin Essentials for the Java Eyes
Less Typing
Sensible Warnings
Prefer val over var
Improved Equality Check
String Templates
Raw Strings
More Expressions, Fewer Statements
Wrapping Up
3. Working with Functions
Creating Functions
Default and Named Arguments
vararg and Spread
Destructuring
Wrapping Up
4. External Iteration and Argument Matching
Range and Iteration
Iterating over Arrays and Lists
When It’s Time to Use when
Wrapping Up
5. Using Collections
Flavors of Collections
Using Pair and Triple
Arrays of Objects and Primitives
Using List
Using Set
Using Map
Wrapping Up
6. Type Safety to Save the Day
Any and Nothing Classes
Nullable References
Type Checking and Casting
Explicit Type Casting
Generics: Variance and Constraints of Parametric Types
Reified Type Parameters
Wrapping Up
Part II. Object-Oriented Kotlin
7. Objects and Classes
Objects and Singletons
Creating Classes
Companion Objects and Class Members
Creating Generics Classes
Data Classes
Wrapping Up
8. Class Hierarchies and Inheritance
Creating Interfaces and Abstract Classes
Nested and Inner Classes
Inheritance
Sealed Classes
Creating and Using Enums
Wrapping Up
9. Extension Through Delegation
When to Choose Delegation over Inheritance?
Designing with Delegates
Delegating to a Parameter
Dealing with Method Collisions
Caveats of Kotlin Delegation
Delegating Variables and Properties
Built-in Standard Delegates
Wrapping Up
Part III. Functional Kotlin
10. Functional Programming with Lambdas
The Functional Style
Lambda Expressions
Lambdas and Anonymous Functions
Closures and Lexical Scoping
Non-Local and Labeled return
Inlining Functions with Lambdas
Wrapping Up
11. Internal Iteration and Lazy Evaluation
External vs. Internal Iterators
Internal Iterators
Sequences for Lazy Evaluation
Wrapping Up
Part IV. Elegant and Efficient Kotlin
12. Fluency in Kotlin
Overloading Operators
Injecting Using Extension Functions and Properties
Extending Functions
Function Fluency with infix
Fluency with Any Object
Implicit Receivers
Wrapping Up
13. Creating Internal DSLs
Types and Characteristics of DSLs
Kotlin for Internal DSLs
Challenges in Building for Fluency
Type-Safe Builders
Narrowing Access with Scope Control
Wrapping Up
14. Programming Recursion and Memoization
The Power and Perils of Recursion
Tail Call Optimization
Memoization
Applying Memoization to Dynamic Programming
Wrapping Up
Part V. Programming Asynchronous Applications
15. Exploring Coroutines
Coroutines and Concurrency
Running Concurrently Using Coroutines
Coroutine Context and Threads
Debugging Coroutines
async and await
A Peek at Continuations
Creating Infinite Sequences
Wrapping Up
16. Asynchronous Programming
Programming Asynchronously
Exception Handling
Cancellations and Timeouts
Wrapping Up
Part VI. Interop and Testing
17. Intermixing Java and Kotlin
Joint Compilation
Calling Java from Kotlin
Calling Kotlin from Java
Wrapping Up
18. Unit Testing with Kotlin
The Code Under Test
Getting the Project Files
Starting with a Canary Test
Writing Empirical Tests
Writing Data-Driven Tests
Mocking Out Dependencies
Testing Top-Level Functions
Testing Coroutines and Asynchronous Calls
Integrating with the Service
Viewing the Code Coverage
Taking the App for a Drive
Wrapping Up
19. Programming Spring Applications with KotlinProgramming Spring Applications with Kotlin
Creating a Starter Project
Creating a Controller
Creating an Entity Class
Creating a Repository Interface
Creating a Service
Integrating the Service with Controller
Taking It for a Ride
Wrapping Up
20. Writing Android Applications with Kotlin
Creating a Project
Defining Domain Objects
Creating Layouts
Implementing the Activity
Updating the RecyclerView
Seeing the App in Action
Wrapping Up
A1. Transpiling to JavaScript
A2. Kotlin/Native
A3. Kotlin to WebAssembly
 Bibliography
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Wrapping Up
Next
Next Chapter
Part VI. Interop and Testing
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset