Kotlin Language Documentation

Kotlin Language Documentation

Table of Contents

Overview

7

Using Kotlin for Server-side Development

7

Using Kotlin for Android Development

9

Kotlin JavaScript Overview

11

Kotlin/Native for Native

13

Coroutines for asynchronous programming and more

15

Multiplatform Programming

16

What's New in Kotlin 1.1

19

What's New in Kotlin 1.2

30

What's New in Kotlin 1.3

39

Standard library

45

Tooling

47

Getting Started

48

Basic Syntax

48

Idioms

55

Coding Conventions

60

Basics

78

Basic Types

78

Packages

88

Control Flow: if, when, for, while

90

Returns and Jumps

94

Classes and Objects

97

Classes and Inheritance

97

Properties and Fields

105

Interfaces

109

Visibility Modifiers

112

Extensions

115

2

Data Classes

120

Sealed Classes

122

Generics

123

Nested and Inner Classes

130

Enum Classes

131

Object Expressions and Declarations

133

Inline classes

138

Delegation

143

Delegated Properties

145

Functions and Lambdas

152

Functions

152

Higher-Order Functions and Lambdas

159

Inline Functions

167

Collections

171

Kotlin Collections Overview

171

Constructing Collections

176

Iterators

179

Ranges and Progressions

181

Sequences

183

Collection Operations Overview

186

Collection Transformations

188

Filtering

192

plus and minus Operators

195

Grouping

196

Retrieving Collection Parts

197

Retrieving Single Elements

200

Collection Ordering

203

Collection Aggregate Operations

206

Collection Write Operations

208

3

List Specific Operations

210

Set Specific Operations

215

Map Specific Operations

216

Multiplatform Programming

220

Platform-Specific Declarations

220

Building Multiplatform Projects with Gradle

222

Other

260

Destructuring Declarations

260

Type Checks and Casts: 'is' and 'as'

263

This Expression

267

Equality

268

Operator overloading

269

Null Safety

274

Exceptions

278

Annotations

281

Reflection

286

Scope Functions

291

Type-Safe Builders

299

Experimental API Markers

306

Reference

312

Keywords and Operators

312

Grammar

318

Java Interop

337

Calling Java code from Kotlin

337

Calling Kotlin from Java

351

JavaScript

362

Dynamic Type

362

Calling JavaScript from Kotlin

364

4

Calling Kotlin from JavaScript

367

JavaScript Modules

370

JavaScript Reflection

374

JavaScript DCE

375

Example

376

Native

377

Concurrency in Kotlin/Native

377

Immutability in Kotlin/Native

381

Kotlin/Native libraries

382

Advanced topics

383

Platform libraries

385

Kotlin/Native interoperability

386

Kotlin/Native interoperability with Swift/Objective-C

397

CocoaPods integration

404

Kotlin/Native Gradle plugin

407

Coroutines

426

Table of contents

426

Additional references

426

Coroutine Basics

427

Cancellation and Timeouts

433

Composing Suspending Functions

438

Coroutine Context and Dispatchers

443

Asynchronous Flow

454

Channels

477

Exception Handling

486

Shared mutable state and concurrency

495

Select Expression (experimental)

501

Tools

508

Documenting Kotlin Code

508

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download