Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

animation { 0.frame { x = 10 y = 20 } 50.frame { y = 70 rotation = 90 } 100.frame { x = 0 y = -20 rotation = 40 } }

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

/** * Example of a higher-order function */ fun Iterable.map(transform: (T) -> R): MutableList { val destination = emptyMutableList() this.forEach { value -> // Invoke the transform function with the current value val transformedValue = transform(value) destination.add(transformedValue) } return destination }

Slide 8

Slide 8 text

/** * Example of a higher-order function */ fun Iterable.map(transform: (T) -> R): MutableList { val destination = emptyMutableList() this.forEach { value -> // Invoke the transform function with the current value val transformedValue = transform(value) destination.add(transformedValue) } return destination }

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

/** * Calls the specified function [block] with `this` value * as its receiver and returns `this` value. */ public inline fun T.apply(block: T.() -> Unit): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() return this }

Slide 11

Slide 11 text

/** * Calls the specified function [block] with `this` value * as its receiver and returns `this` value. */ public inline fun T.apply(block: T.() -> Unit): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() return this }

Slide 12

Slide 12 text

/** * Calls the specified function [block] with `this` value * as its receiver and returns `this` value. */ public inline fun T.apply(block: T.() -> Unit): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() return this }

Slide 13

Slide 13 text

/** * Calls the specified function [block] with `this` value * as its receiver and returns `this` value. */ public inline fun T.apply(block: T.() -> Unit): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() return this }

Slide 14

Slide 14 text

/** * Calls the specified function [block] with `this` value * as its receiver and returns `this` value. */ public inline fun T.apply(block: T.() -> Unit): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block(this) return this }

Slide 15

Slide 15 text

val user = User(name = "John", age = 30, city = "Berlin") user.apply { age = 31 city = "Hamburg" }

Slide 16

Slide 16 text

val user = User(name = "John", age = 30, city = "Berlin") user.apply { this.age = 31 this.city = "Hamburg" }

Slide 17

Slide 17 text

animation { // This is a higher-order function 0.frame { x = 10 y = 20 } 50.frame { y = 70 rotation = 90 } 100.frame { x = 0 y = -20 rotation = 40 } }

Slide 18

Slide 18 text

class AnimationDSLBuilder { }

Slide 19

Slide 19 text

fun animation(init: AnimationDSLInit) = AnimationDSLBuilder().apply(init)

Slide 20

Slide 20 text

animation { }

Slide 21

Slide 21 text

animation { frame(0) { x = 10 y = 20 } }

Slide 22

Slide 22 text

fun frame(frameNumber: Int, frameBlock: FrameInit) { val frame = Frame().apply(frameBlock) frames[frameNumber] = frame }

Slide 23

Slide 23 text

animation { frame(0) { x = 10 y = 20 } 0.frame { x = 10 y = 20 } }

Slide 24

Slide 24 text

fun Int.frame(frameBlock: FrameInit) { val frame = Frame().apply(frameBlock) frames[this] = frame }

Slide 25

Slide 25 text

animation { frame(0) { x = 10 y = 20 } 0.frame { x = 10 y = 20 } 20 { rotation = 40 } }

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content