Kotlin · From scratch
Kotlin4Noobs
From your first val to coroutines, one step at a time. A free guide in English and Portuguese, with examples you run right in the page.
15 topics · 56 runnable examples
Environment setup
Getting Kotlin onto your machine.
Principles
The building blocks of every Kotlin program.
- val02Variables
valandvar, mutability and the scope of variables.ValVarVariable scopes+1 - Int03Data typesNumbers, characters, booleans, strings and arrays.IntegersFloating pointChar+7
- fun04FunctionsDeclaration, parameters, return values and single-expression functions.SyntaxExtension functionsArithmetic operators+1
- +=05OperatorsArithmetic, comparison, logical, range and type operators.Arithmetic operatorsCompound assignment operatorsComparison operators+8
- when06Conditional expressions
ifandwhenas expressions that return a value.IfWhen - for07Loops
for,while,do-while, ranges and flow control.ForWhile and do-while - apply08Scope functions
let,run,with,applyandalso, and when to use each one.letapplyalso+1
Data structures
Collections, classes and generic types.
- List09CollectionsLists, sets and maps, read-only and mutable.ListSetMap+2
- class10Classes and objectsClasses, constructors, inheritance, data classes and objects.ClassData classEnum class+6
- <T>11GenericsGeneric classes and functions, constraints and variance.Generic classesGeneric functionsConstraints+3
Error handling
Exceptions and the type system against null.
Asynchronous programming
Concurrent code with coroutines.
Best practices
Writing Kotlin the way Kotlin is written.
More
Tools, examples of real code and the community.