The Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified
Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners
https://goalkicker.com/
章節目錄
1-1
Content list
1-2
About
1-3
Chapter 1: Getting started with Kotlin
1-4
Section 1.1: Hello World
1-5
Section 1.2: Hello World using a Companion Object
1-6
Section 1.3: Hello World using an Object Declaration
1-7
Section 1.4: Main methods using varargs
1-8
Section 1.5: Compile and Run Kotlin Code in Command Line
1-9
Section 1.6: Reading input from Command Line
1-10
Chapter 2: Basics of Kotlin
1-11
Section 2.1: Basic examples
1-12
Chapter 3: Strings
1-13
Section 3.1: String Equality
1-14
Section 3.2: String Literals
1-15
Section 3.3: Elements of String
1-16
Section 3.4: String Templates
1-17
Chapter 4: Arrays
1-18
Section 4.1: Generic Arrays
1-19
Section 4.2: Arrays of Primitives
1-20
Section 4.3: Create an array
1-21
Section 4.4: Create an array using a closure
1-22
Section 4.5: Create an uninitialized array
1-23
Section 4.6: Extensions
1-24
Section 4.7: Iterate Array
1-25
Chapter 5: Collections
1-26
Section 5.1: Using list
1-27
Section 5.2: Using map
1-28
Section 5.3: Using set
1-29
Chapter 6: Enum
1-30
Section 6.1: Initialization
1-31
Section 6.2: Functions and Properties in enums
1-32
Section 6.3: Simple enum
1-33
Section 6.4: Mutability
1-34
Chapter 7: Functions
1-35
Section 7.1: Function References
1-36
Section 7.2: Basic Functions
1-37
Section 7.3: Inline Functions
1-38
Section 7.4: Lambda Functions
1-39
Section 7.5: Operator functions
1-40
Section 7.6: Functions Taking Other Functions
1-41
Section 7.7: Shorthand Functions
1-42
Chapter 8: Vararg Parameters in Functions
1-43
Section 8.1: Basics: Using the vararg keyword
1-44
Section 8.2: Spread Operator: Passing arrays into vararg functions
1-45
Chapter 9: Conditional Statements
1-46
Section 9.1: When-statement argument matching
1-47
Section 9.2: When-statement as expression
1-48
Section 9.3: Standard if-statement
1-49
Section 9.4: If-statement as an expression
1-50
Section 9.5: When-statement instead of if-else-if chains
1-51
Section 9.6: When-statement with enums
1-52
Chapter 10: Loops in Kotlin
1-53
Section 10.1: Looping over iterables
1-54
Section 10.2: Repeat an action x times
1-55
Section 10.3: Break and continue
1-56
Section 10.4: Iterating over a Map in kotlin
1-57
Section 10.5: Recursion
1-58
Section 10.6: While Loops
1-59
Section 10.7: Functional constructs for iteration
1-60
Chapter 11: Ranges
1-61
Section 11.1: Integral Type Ranges
1-62
Section 11.2: downTo() function
1-63
Section 11.3: step() function
1-64
Section 11.4: until function
1-65
Chapter 12: Regex
1-66
Section 12.1: Idioms for Regex Matching in When Expression
1-67
Section 12.2: Introduction to regular expressions in Kotlin
1-68
Chapter 13: Basic Lambdas
1-69
Section 13.1: Lambda as parameter to filter function
1-70
Section 13.2: Lambda for benchmarking a function call
1-71
Section 13.3: Lambda passed as a variable
1-72
Chapter 14: Null Safety
1-73
Section 14.1: Smart casts
1-74
Section 14.2: Assertion
1-75
Section 14.3: Eliminate nulls from an Iterable and array
1-76
Section 14.4: Null Coalescing / Elvis Operator
1-77
Section 14.5: Nullable and Non-Nullable types
1-78
Section 14.6: Elvis Operator (?:)
1-79
Section 14.7: Safe call operator
1-80
Chapter 15: Class Delegation
1-81
Section 15.1: Delegate a method to another class
1-82
Chapter 16: Class Inheritance
1-83
Section 16.1: Basics: the 'open' keyword
1-84
Section 16.2: Inheriting fields from a class
1-85
Section 16.3: Inheriting methods from a class
1-86
Section 16.4: Overriding properties and methods
1-87
Chapter 17: Visibility Modifiers
1-88
Section 17.1: Code Sample
1-89
Chapter 18: Generics
1-90
Section 18.1: Declaration-site variance
1-91
Section 18.2: Use-site variance
1-92
Chapter 19: Interfaces
1-93
Section 19.1: Interface with default implementations
1-94
Section 19.2: Properties in Interfaces
1-95
Section 19.3: super keyword
1-96
Section 19.4: Basic Interface
1-97
Section 19.5: Conflicts when Implementing Multiple Interfaces with Default Implementations
1-98
Chapter 20: Singleton objects
1-99
Section 20.1: Use as replacement of static methods/fields of java
1-100
Section 20.2: Use as a singleton
1-101
Chapter 21: coroutines
1-102
Section 21.1: Simple coroutine which delay's 1 second but not blocks
1-103
Chapter 22: Annotations
1-104
Section 22.1: Meta-annotations
1-105
Section 22.2: Declaring an annotation
1-106
Chapter 23: Type aliases
1-107
Section 23.1: Function type
1-108
Section 23.2: Generic type
1-109
Chapter 24: Type-Safe Builders
1-110
Section 24.1: Type-safe tree structure builder
1-111
Chapter 25: Delegated properties
1-112
Section 25.1: Observable properties
1-113
Section 25.2: Custom delegation
1-114
Section 25.3: Lazy initialization
1-115
Section 25.4: Map-backed properties
1-116
Section 25.5: Delegate Can be used as a layer to reduce boilerplate
1-117
Chapter 26: Reflection
1-118
Section 26.1: Referencing a class
1-119
Section 26.2: Inter-operating with Java reflection
1-120
Section 26.3: Referencing a function
1-121
Section 26.4: Getting values of all properties of a class
1-122
Section 26.5: Setting values of all properties of a class
1-123
Chapter 27: Extension Methods
1-124
Section 27.1: Potential Pitfall: Extensions are Resolved Statically
1-125
Section 27.2: Top-Level Extensions
1-126
Section 27.3: Lazy extension property workaround
1-127
Section 27.4: Sample extending Java 7+ Path class
1-128
Section 27.5: Sample extending long to render a human readable string
1-129
Section 27.6: Sample extending Java 8 Temporal classes to render an ISO formatted string
1-130
Section 27.7: Using extension functions to improve readability
1-131
Section 27.8: Extension functions to Companion Objects (appearance of Static functions)
1-132
Section 27.9: Extensions for easier reference View from code
1-133
Chapter 28: DSL Building
1-134
Section 28.1: Infix approach to build DSL
1-135
Section 28.2: Using operators with lambdas
1-136
Section 28.3: Overriding invoke method to build DSL
1-137
Section 28.4: Using extensions with lambdas
1-138
Chapter 29: Idioms
1-139
Section 29.1: Serializable and serialVersionUid in Kotlin
1-140
Section 29.2: Delegate to a class without providing it in the public constructor
1-141
Section 29.3: Use let or also to simplify working with nullable objects
1-142
Section 29.4: Use apply to initialize objects or to achieve method chaining
1-143
Section 29.5: Fluent methods in Kotlin
1-144
Section 29.6: Filtering a list
1-145
Section 29.7: Creating DTOs (POJOs/POCOs)
1-146
Chapter 30: RecyclerView in Kotlin
1-147
Section 30.1: Main class and Adapter
1-148
Chapter 31: logging in kotlin
1-149
Section 31.1: kotlin.logging
1-150
Chapter 32: Exceptions
1-151
Section 32.1: Catching exception with try-catch-finally
1-152
Chapter 33: JUnit
1-153
Section 33.1: Rules
1-154
Chapter 34: Kotlin Android Extensions
1-155
Section 34.1: Using Views
1-156
Section 34.2: Configuration
1-157
Section 34.3: Painful listener for getting notice, when the view is completely drawn now is so simple and awesome with Kotlin's extension
1-158
Section 34.4: Product flavors
1-159
Chapter 35: Kotlin for Java Developers
1-160
Section 35.1: Declaring Variables
1-161
Section 35.2: Quick Facts
1-162
Section 35.3: Equality & Identity
1-163
Section 35.4: IF, TRY and others are expressions, not statements
1-164
Chapter 36: Java 8 Stream Equivalents
1-165
Section 36.1: Accumulate names in a List
1-166
Section 36.2: Collect example #5 - find people of legal age, output formatted string
1-167
Section 36.3: Collect example #6 - group people by age, print age and names together
1-168
Section 36.4: Dierent Kinds of Streams #7 - lazily iterate Doubles, map to Int, map to String, print each
1-169
Section 36.5: Counting items in a list after filter is applied
1-170
Section 36.6: Convert elements to strings and concatenate them, separated by commas
1-171
Section 36.7: Compute sum of salaries of employee
1-172
Section 36.8: Group employees by department
1-173
Section 36.9: Compute sum of salaries by department
1-174
Section 36.10: Partition students into passing and failing
1-175
Section 36.11: Names of male members
1-176
Section 36.12: Group names of members in roster by gender
1-177
Section 36.13: Filter a list to another list
1-178
Section 36.14: Finding shortest string a list
1-179
Section 36.15: Dierent Kinds of Streams #2 - lazily using first item if exists
1-180
Section 36.16: Dierent Kinds of Streams #3 - iterate a range of Integers
1-181
Section 36.17: Dierent Kinds of Streams #4 - iterate an array, map the values, calculate the average
1-182
Section 36.18: Dierent Kinds of Streams #5 - lazily iterate a list of strings, map the values, convert to Int, find max
1-183
Section 36.19: Dierent Kinds of Streams #6 - lazily iterate a stream of Ints, map the values, print results
1-184
Section 36.20: How streams work - filter, upper case, then sort a list
1-185
Section 36.21: Dierent Kinds of Streams #1 - eager using first item if it exists
1-186
Section 36.22: Collect example #7a - Map names, join together with delimiter
1-187
Section 36.23: Collect example #7b - Collect with SummarizingInt
1-188
Chapter 37: Kotlin Caveats
1-189
Section 37.1: Calling a toString() on a nullable type
1-190
Appendix A: Configuring Kotlin build
1-191
Section A.1: Gradle configuration
1-192
Section A.2: Using Android Studio
1-193
Section A.3: Migrating from Gradle using Groovy script to Kotlin script