- Main.kt - no package; no semicolon
- Hello1, Hello2 - top-level function; main with args & no args; string templates, Array syntax & wrappers; if expression
- Variables - read-only & mutable variables; type inference
- Functions1, Functions2, FunctionsJ - expression body; Unit; top-level, member, local; calling from Java; named & default args; @JvmOverloads
- Conditionals - if & when; is & smart cast;
- Loops - for, in, ranges
- InChecksAndRanges - in use cases; ranges
- CheckingIdentifier - small task to practice ranges
- Exceptions - no checked/unchecked; throw & try expressions; @Throws
- ExtensionFunctions - extension functions, examples, standard library
- SumExtensionFunction - small task to create extension function
- CallingExtensions - how extensions interact with inheritance and can extensions hide members
- With extensions, we can keep our classes and interfaces APIs minimal and write everything else as extension, but keep them close together.
- We can use extensions when we don't control some class or interface, many existing Java libraries have companion libraries with a number of extensions.
- NullableTypes - nullable types; nullability operators
- EmptyOrNull - small task to check if string is null or empty
- SafeCasts - a safe way to cast an expression to a type
- Nullability is very important
- Lambdas - lambda syntax
- CollectionsOps - common operations on collections
- OperationsQuiz - practice common operations on collections
- InterchangeablePredicates - small task to practice none, any, all
- FunctionTypes - function types, nullability
- MemberReferences - member references, function references, bound, non-bound
- ReturnFromLambda - how return behaves with lambdas
- Kotlin is not purely functional language, but rather combines OOP and functional styles
- Properties - properties, fields, accessors
- InterfaceAndExtProperties - properties in interfaces, extension properties
- LazyAndLateInit - lazy properties, late initialization
- Defaults are different in Kotlin -
public
andfinal
by default - If you want to make it non-final, you have to set it explicitly as
open
- No package private visibility in Kotlin, use
internal
for that - visible in module - Module is a set of Kotlin files compiled together (IntelliJ IDEA, Maven project, Gradle source set)
- So we have there modifiers:
public
,protected
private
,internal
. Then:final
,open
,abstract
. Alsooverride
. - In Kotlin we can have multiple classes in the same file, while in Java we prefer one class per file. One file can additionally contain multiple top-level functions, properties, etc.
- In Kotlin, package doesn't have to correspond to directory structure - we can have
org.company.store
package, but it can be physically located in top levelstore
folder for example. Good recommendatioon is to simply omitorg.company
ororg.company.project
from directory structure. - CtxInherit - constructors, inheritance syntax
- ClassModifiers - class modifiers, enum, data, equality, sealed, inner, nested, class delegation
- Objects - objects, object declaration, object expression, companion object, "static" members
- Constants
- Generics
- OperatorOverloading - operator overloading
- Conventions
- LibraryFunctions - by inlining, library functions look like built-in language construct
- Inline - the power of inline
- Sequences - collection vs sequences, how to create mix...
- LambdaWithReceiver - lambda with receiver
- Types - types, type hierarchy, Any, Unit, Nothing, nullable types, collection types