Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Write down a plan
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Aug 16, 2020
1 parent f9ea909 commit 5e6ad57
Showing 1 changed file with 158 additions and 6 deletions.
164 changes: 158 additions & 6 deletions slides/content/01-kotlin/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,33 @@ Similar to Scala. The keyword `def` is replaced by `fun`
val x = 10 // constant
var y = 20 // variable, can be reassigned
fun foo() = 20 // function definition, single expression
fun foo() { // same as above with multiple expression
return 20 // requires return in this form
fun bar(): Int { // same as above with multiple expression
return 20 // requires a return in this form...
}
fun baz() { } // Unless it returns Unit

```

---

# Kotlin 101
## Function parameters, return types
## Function parameters and return types

Much like Scala:

* All parameters are named, but can be invoked positionally as well
* Parameters can have defaults
* Types are annotatedd after the parameter name
* Invocation can be positional or by name, with the rule that once a named parameter is used, subsequent parameters must be named as well

```kotlin
fun foo(): Int = 10 // types are annotated with a column and the type name
fun foo() = 10 // return type annotation can be omitted (if the compiler can infer it)
fun foo(a: Int, b: String): Int = TODO() // TODO() is a builtin
// MANCANO I DEFAULT!!!!
function throwing a `NotImplementedError`
foo(1, "bar") // OK, positional
foo(a = 1, b = "bar") // OK, named
foo(1, b = "bar") // OK, hybrid
foo(a = 1, "bar") // error: no value passed for parameter 'b'
```

---
Expand Down Expand Up @@ -129,4 +141,144 @@ fun main(arguments: Array<String>) = println("Hello World") // Valid entry point
fun main(arguments: Array<String>) {
println("Hello World") // Return type is Unit, no need to return
}
```
```

---

# Kotlin 101
## Program entry point


---

# TODOS

## 101
type hierarchy (top and bottom types)
nullable types
boolean types
numeric types
unsigned integers
string templates
multiline strings
packages and imports
compile time constants
varargs
infix
local functions
inline functions

## flow control
if
for
while
break and continue
when vs. pattern matching
labeled jumping (incl. qualified return)

## oop
classes and members (methods and properties)
object creation (no new)
access to members (invoke vs named access)
inheritance and open
inheritance and override
abstract
inheritance and disambiguation by `super<Class>`
interfaces and subtyping
implementation of members in interfaces (no backing field)
constructors
init blocks
secondary constructors
nullability and `lateinit`
getters
setters
accessors in interfaces
backing fields, `field`
objects
companion objects
visibility
controlling visibility of properties (`private set`)
equality / hashing / toString

## generics
syntax for functions
syntax for classes
type bounds
`where`
variance
use site variance and type projection
declaration site variance
star-projection
reified types
invocation of reified types

## basic collections?
list / mutablelist
set / mutableset
map / mutablemap
`in`

## extended OOP
data classes
copy / equals / toString
destructuring declarations
Pair / Triple
sealed classes
sealing and when
nested classes
inner classes
enum classes
anonymous classes via object expression
type aliasing
delegation and `by`
contract implementation by delegation (favor composition over inheritance)
delegated properties and variables
delegated properties https://kotlinlang.org/docs/reference/delegated-properties.html
lazy
observable
delegation via map (mutability via MutableMap)
implementing a custom delegate for properties

## functional kotlin
function types
function types and nullability
lambda expressions
trailing lambdas
implicit single parameters
closures
destructuring in lambdas
anonymous functions (rarely used)
invoke convention
inline functions

## extensions
extension functions vs implicits
extension properties (no backing field)
nullable receivers
companion extensions
generic extensions
extensions resolution
extension members (scope control)
visibility of private members

## extensions + functional
function types with receiver

## standard library
let / run / apply / with
arrays
primitive arrays
ranges

## performance
tail recursion
inline functions
noinline
crossinline
inline classes -- mentioned and skipped, ref to https://kotlinlang.org/docs/reference/inline-classes.html

## java interop
@JvmOverloads
@JvmDefault

## DSLs in Kotlin (type-safe builders)

0 comments on commit 5e6ad57

Please sign in to comment.