Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition
- Length: 500 pages
- Edition: 2
- Language: English
- Publisher: Big Nerd Ranch Guides
- Publication Date: 2021-10-25
- ISBN-10: 0136891055
- ISBN-13: 9780136891055
- Sales Rank: #406254 (See Top 100 Books)
Kotlin is a statically typed programming language designed to interoperate with Java and fully supported by Google on the Android operating system. It is also a multiplatform language that can be used to write code that can be shared across platforms including macOS, iOS, Windows, and JavaScript.
Based on Big Nerd Ranch’s popular Kotlin Essentials course, this guide shows you how to work effectively with Kotlin through hands-on examples and clear explanations of key Kotlin concepts and foundational APIs. Written for Kotlin 1.5, this book will also introduce you to JetBrains’ IntelliJ IDEA development environment.
Whether you are an experienced developer or are learning your first programming language – and whether you are interested in Kotlin for Android, server-side, or multiplatform projects – the authors will guide you from first principles to advanced Kotlin usage. By the end of this book, you will be empowered to create reliable, concise applications in Kotlin.
Title Page Dedication Acknowledgments Table of Contents Introducing Kotlin Why Kotlin? Who Is This Book For? How to Use This Book For the More Curious Challenges Typographical conventions Using an eBook Looking Forward I. Getting Started 1. Your First Kotlin Application Installing IntelliJ IDEA Your First Kotlin Project Creating your first Kotlin file Running your Kotlin file Compilation and execution of Kotlin/JVM code The Kotlin REPL For the More Curious: Why Use IntelliJ? For the More Curious: Targeting the JVM Challenge: REPL Arithmetic 2. Variables, Constants, and Types Types Declaring a Variable Kotlin’s Built-In Types Read-Only Variables Type Inference Compile-Time Constants Inspecting Kotlin Bytecode For the More Curious: Java Primitive Types in Kotlin Challenge: hasSteed Challenge: The Unicorn’s Horn Challenge: Magic Mirror II. Basic Syntax 3. Conditionals if/else Statements Adding more conditions Nested if/else statements More elegant conditionals Logical operators Conditional expressions Removing braces from if/else expressions Ranges when Expressions when expressions with variable declarations when expressions without arguments Challenge: Trying Out Some Ranges 4. Functions Extracting Code to Functions Anatomy of a Function Function header Visibility modifier Function name declaration Function parameters Function return type Function body Function scope Calling a Function Writing Your Own Functions Default Arguments Single-Expression Functions Unit Functions Named Function Arguments For the More Curious: The Nothing Type For the More Curious: File-Level Functions in Java For the More Curious: Function Overloading For the More Curious: Function Names in Backticks 5. Numbers Numeric Types Integers Floating Point Numbers Formatting a Double Converting Between Numeric Types For the More Curious: Unsigned Numbers For the More Curious: Bit Manipulation 6. Strings String Interpolation Raw Strings Reading Console Input Converting Strings to Numbers Regular Expressions String Manipulation Strings are immutable String Comparison For the More Curious: Unicode 7. Null Safety and Exceptions Nullability Kotlin’s Explicit Null Type Compile Time vs Runtime Null Safety Option one: checking for null values with an if statement Option two: the safe call operator Option two and a half: using safe calls with let The null coalescing operator Option three: the non-null assertion operator Exceptions Throwing an exception Handling exceptions Try/catch expressions Preconditions For the More Curious: Custom Exceptions For the More Curious: Checked vs Unchecked Exceptions III. Introduction to Functional Programming and Collections 8. Lambda Expressions and the Function Type Introducing NyetHack Anonymous Functions Lambda Expressions The function type Implicit returns Function arguments The it identifier Accepting multiple arguments Type Inference Support More Effective Lambdas Defining a Function That Accepts a Function Trailing lambda syntax Function Inlining Lambdas and the Kotlin Standard Library For the More Curious: Function References For the More Curious: Capturing Lambdas Challenge: New Titles and Moods 9. Lists and Sets Lists Accessing a list’s elements Index boundaries and safe index access Checking the contents of a list Changing a list’s contents Iteration Reading a File into a List Destructuring Sets Creating a set Adding elements to a set while Loops Collection Conversion For the More Curious: Array Types For the More Curious: Read-Only vs Immutable For the More Curious: The break Expression For the More Curious: Return Labels Challenge: Formatted Tavern Menu Challenge: Advanced Formatted Tavern Menu 10. Maps Creating a Map Accessing Map Values Adding Entries to a Map Modifying Map Values Converting Between Lists and Maps Iterating Through a Map Challenge: Complex Orders 11. Functional Programming Basics Transforming Data map associate Destructuring with functional programming flatMap map vs flatMap Filtering Data filter Combining Data zip Why Functional Programming? Sequences For the More Curious: Profiling For the More Curious: Aggregating Data reduce fold sumBy For the More Curious: The vararg Keyword For the More Curious: Arrow.kt Challenge: Reversing the Values in a Map Challenge: Finding the Most-Liked Menu Item 12. Scope Functions apply let run with also takeIf Using Scope Functions IV. Object-Oriented Programming 13. Classes Defining a Class Constructing Instances Class Functions Visibility and Encapsulation Class Properties Property getters and setters Property visibility Computed properties Using Packages For the More Curious: A Closer Look at var and val Properties For the More Curious: Guarding Against Mutability For the More Curious: Package Private 14. Initialization Constructors Primary constructors Defining properties in a primary constructor Secondary constructors Default arguments Named arguments Initializer Blocks Initialization Order Delaying Initialization Late initialization Lazy initialization For the More Curious: Initialization Gotchas For the More Curious: Property Delegates Challenge: The Riddle of Excalibur 15. Inheritance Defining the Room Class Creating a Subclass Type Checking The Kotlin Type Hierarchy Type casting Smart casting Refactoring the Tavern For the More Curious: Any For the More Curious: The Safe Cast Operator 16. Objects, Data Classes, and Enums The object Keyword Object declarations Object expressions Companion objects Nested Classes Data Classes toString equals and hashCode copy Destructuring declarations Enumerated Classes Operator Overloading Exploring the World of NyetHack For the More Curious: Defining Structural Comparison For the More Curious: Algebraic Data Types For the More Curious: Value Classes Challenge: More Commands Challenge: Implementing a World Map Challenge: Ring the Bell 17. Interfaces and Abstract Classes Defining an Interface Implementing an Interface Default Implementations Abstract Classes Combat in NyetHack Challenge: Additional Monsters V. Advanced Kotlin 18. Generics Defining Generic Types Generic Functions Generic Constraints in and out Adding Loot to NyetHack For the More Curious: The reified Keyword 19. Extensions Defining Extension Functions Defining an extension on a superclass Generic extension functions Operator extension functions Extension Properties Extensions on Nullable Types Extensions, Under the Hood Extension Visibility Extensions in the Kotlin Standard Library For the More Curious: Function Literals with Receivers Challenge: Frame Extension 20. Coroutines Blocking Calls Enabling Coroutines Coroutine Builders Coroutine Scopes Structured Concurrency Using an HTTP Client async and await For the More Curious: Race Conditions For the More Curious: Server-Side Kotlin Challenge: No Cancellations 21. Flows Setting Up a Flow MutableStateFlow Flow Termination Flow Transformations Error Handling in Flows For the More Curious: SharedFlow 22. Channels Dividing Work with Channels Sending to a Channel Receiving from a Channel Closing a Channel Joining Jobs For the More Curious: Other Channel Behaviors Rendezvous channels Buffered channels Unlimited channels Conflated channels VI. Interoperation and Multiplatform Applications 23. Java Interoperability Interoperating with a Java Class Interoperability and Nullity Type Mapping Getters, Setters, and Interoperability Beyond Classes Exceptions and Interoperability Function Types in Java 24. Introduction to Kotlin Multiplatform What Is Kotlin Multiplatform? Planning Your Multiplatform Project Your First Multiplatform Project Defining a Kotlin/JVM Target Defining Shared Code expect and actual 25. Kotlin/Native Declaring a macOS Target Writing Native Code with Kotlin Launching a Kotlin/Native application Kotlin/Native Outputs For the More Curious: Kotlin Multiplatform Mobile For the More Curious: Other Native Platforms 26. Kotlin/JS Declaring Support for Kotlin/JS Interacting with the DOM The external Keyword Executing Raw JavaScript Dynamic Types For the More Curious: Front-End Frameworks Challenge: Currency Exchange Fees 27. Afterword Where to Go from Here Shameless Plugs Thank You Glossary Index
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.