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

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

val firstName: String = "Drew" val lastName: String? = null

Slide 8

Slide 8 text

val firstName: String = "Drew" val lastName: String? = null

Slide 9

Slide 9 text

val firstName: String = "Drew" val lastName: String? = null

Slide 10

Slide 10 text

val firstName: String = "Drew" val lastName: String? = null

Slide 11

Slide 11 text

val firstName: String = "Drew" val lastName: String? = null

Slide 12

Slide 12 text

val firstName = "Drew" val lastName: String? = null

Slide 13

Slide 13 text

fun sum(a: Int, b: Int): Int { return a + b }

Slide 14

Slide 14 text

fun sum(a: Int, b: Int): Int { return a + b }

Slide 15

Slide 15 text

fun sum(a: Int, b: Int): Int { return a + b }

Slide 16

Slide 16 text

fun sum(a: Int, b: Int): Int { return a + b }

Slide 17

Slide 17 text

fun sum(a: Int, b: Int): Int = a + b

Slide 18

Slide 18 text

fun sum(a: Int, b: Int): Int = a + b

Slide 19

Slide 19 text

fun sum(a: Int, b: Int): Int = a + b fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default }

Slide 20

Slide 20 text

fun sum(a: Int, b: Int): Int = a + b fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default }

Slide 21

Slide 21 text

fun sum(a: Int, b: Int): Int = a + b fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default }

Slide 22

Slide 22 text

fun sum(a: Int, b: Int): Int = a + b fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default }

Slide 23

Slide 23 text

fun sum(a: Int, b: Int): Int = a + b fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default } stringOrDefault(name)

Slide 24

Slide 24 text

fun sum(a: Int, b: Int): Int = a + b fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default } stringOrDefault(name) stringOrDefault(name, "missing")

Slide 25

Slide 25 text

"// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 26

Slide 26 text

"// Kotlin val user = User() println("User: " + user.name) "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 27

Slide 27 text

"// Kotlin val user = User() println("User: " + user.name) "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 28

Slide 28 text

"// Kotlin val user = User() println("User: " + user.name) user.name = "Not Drew" "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 29

Slide 29 text

"// Kotlin val user = User() println("User: " + user.name) user.name = "Not Drew" "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 30

Slide 30 text

"// Kotlin val user = User() println("User: ${user.name}") user.name = "Not Drew" "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 31

Slide 31 text

"// Kotlin val user = User() println("User: $user") user.name = "Not Drew" "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 32

Slide 32 text

"// Kotlin val user = User() println("User: $user") user.name = "Not Drew" "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }

Slide 33

Slide 33 text

"// Kotlin class User { var name = "Drew" }

Slide 34

Slide 34 text

"// Kotlin class User { var name = "Drew" }

Slide 35

Slide 35 text

"// Java final User user = new User(); System.out.println("User: " + user.getName()); "// Kotlin class User { var name = "Drew" }

Slide 36

Slide 36 text

"// Java final User user = new User(); System.out.println("User: " + user.getName()); "// Kotlin class User { var name = "Drew" }

Slide 37

Slide 37 text

"// Java final User user = new User(); System.out.println("User: " + user.getName()); user.setName("Not Drew"); "// Kotlin class User { var name = "Drew" }

Slide 38

Slide 38 text

"// Java final User user = new User(); System.out.println("User: " + user.getName()); user.setName("Not Drew"); "// Kotlin class User { var name = "Drew" }

Slide 39

Slide 39 text

"// Kotlin val user = User()

Slide 40

Slide 40 text

"// Kotlin val user = User() user = User()

Slide 41

Slide 41 text

var currentUser = User() currentUser = User() "// Kotlin val user = User() user = User()

Slide 42

Slide 42 text

"// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language }

Slide 43

Slide 43 text

"// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language }

Slide 44

Slide 44 text

"// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language }

Slide 45

Slide 45 text

"// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language } val locale = Locale.GERMANY if (locale.isLanguageEnglish()) { println("The Locale's language is English.") } else { println("The Locale's language is not english") }

Slide 46

Slide 46 text

"// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language } val locale = Locale.GERMANY if (locale.isLanguageEnglish()) { println("The Locale's language is English.") } else { println("The Locale's language is not english") }

Slide 47

Slide 47 text

"// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language } import com.app.isLanguageEnglish val locale = Locale.GERMANY if (locale.isLanguageEnglish()) { println("The Locale's language is English.") } else { println("The Locale's language is not english") }

Slide 48

Slide 48 text

"// Java LocaleKt.isLanguageEnglish(Locale.UK); val locale = Locale.GERMANY if (locale.isLanguageEnglish()) { "//""... } "// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language }

Slide 49

Slide 49 text

"// Kotlin "// file: com/app/locale.kt @file:JvmName("LocaleUtils") fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language } val locale = Locale.GERMANY if (locale.isLanguageEnglish()) { "//""... } "// Java LocaleKt.isLanguageEnglish(Locale.UK);

Slide 50

Slide 50 text

"// Kotlin "// file: com/app/locale.kt @file:JvmName("LocaleUtils") fun Locale.isLanguageEnglish(): Boolean { return language "== Locale.ENGLISH.language } val locale = Locale.GERMANY if (locale.isLanguageEnglish()) { "//""... } "// Java LocaleUtils.isLanguageEnglish(Locale.UK);

Slide 51

Slide 51 text

val executor = Executors.newCachedThreadPool() executor.execute { println("from the background") }

Slide 52

Slide 52 text

val executor = Executors.newCachedThreadPool() executor.execute { println("from the background") }

Slide 53

Slide 53 text

val worker = Worker() val executor = Executors.newCachedThreadPool() executor.execute(worker"::doWork) class Worker { fun doWork() { println("from the background") } }

Slide 54

Slide 54 text

val worker = Worker() val executor = Executors.newCachedThreadPool() executor.execute(worker"::doWork) class Worker { fun doWork() { println("from the background") } }

Slide 55

Slide 55 text

val work = { println("from the background") } val executor = Executors.newCachedThreadPool() executor.execute(work)

Slide 56

Slide 56 text

val work = { println("from the background") } val executor = Executors.newCachedThreadPool() executor.execute(work)

Slide 57

Slide 57 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... }

Slide 58

Slide 58 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... }

Slide 59

Slide 59 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val names = listOf("Drew", "Ahsan", "Shivangi") val drews = names.filter({ name !-> name "== "Drew" })

Slide 60

Slide 60 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter({ name !-> name "== "Drew" }) val names = listOf("Drew", "Ahsan", "Shivangi")

Slide 61

Slide 61 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter({ it "== "Drew" }) val names = listOf("Drew", "Ahsan", "Shivangi")

Slide 62

Slide 62 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter() { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi")

Slide 63

Slide 63 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi")

Slide 64

Slide 64 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi") val ahsans = names.filterTo(mutableSetOf()) { it == "Ahsan" }

Slide 65

Slide 65 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi") val ahsans = names.filterTo(mutableSetOf()) { it == "Ahsan" }

Slide 66

Slide 66 text

fun List.filter(predicate: (T) "-> Boolean): List { "// ""... } val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi") val ahsans = names.filterTo(mutableSetOf()) { it == "Ahsan" }

Slide 67

Slide 67 text

val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi") fun List.filter(predicate: (T) "-> Boolean): List { "// ""... }

Slide 68

Slide 68 text

val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi") inline fun List.filter(predicate: (T) "-> Boolean): List { "// ""... }

Slide 69

Slide 69 text

inline fun List.filter(predicate: (T) "-> Boolean): List { val destination = mutableListOf() for (item in this) { if (predicate(item)) destination.add(item) } return destination } val names = listOf("Drew", "Ahsan", "Shivangi") val drews = names.filter { it "== "Drew" }

Slide 70

Slide 70 text

inline fun List.filter(predicate: (T) "-> Boolean): List { val destination = mutableListOf() for (item in this) { if (predicate(item)) destination.add(item) } return destination } val destination = mutableListOf() for (item in names) { if (item "== "Drew") destination.add(item) } val drews: List = destination

Slide 71

Slide 71 text

class User { val name = "drew" }

Slide 72

Slide 72 text

class User(name: String) { val name = name }

Slide 73

Slide 73 text

class User(val name: String) { }

Slide 74

Slide 74 text

class User(val name: String)

Slide 75

Slide 75 text

class User(val name: String) val drew = User("Drew") println("Hello, $drew")

Slide 76

Slide 76 text

class User(val name: String) val drew = User("Drew") println("Hello, $drew") Hello, User@8c64f2bc

Slide 77

Slide 77 text

class User(val name: String) val drew = User("Drew") println("Hello, $drew") Hello, User@8c64f2bc

Slide 78

Slide 78 text

data class User(val name: String) val drew = User("Drew") println("Hello, $drew") Hello, User@8c64f2bc

Slide 79

Slide 79 text

data class User(val name: String) val drew = User("Drew") println("Hello, $drew") Hello, User(name=Drew)

Slide 80

Slide 80 text

data class User(val name: String) val drew = User("Drew") println("Hello, $drew") Hello, User(name=Drew)

Slide 81

Slide 81 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5)

Slide 82

Slide 82 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5)

Slide 83

Slide 83 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5) val updated = drew.copy(age = 6)

Slide 84

Slide 84 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5)

Slide 85

Slide 85 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5) val (name, age) = drew

Slide 86

Slide 86 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5) val (name, age) = drew val (key, value) = Pair("session_id", "1")

Slide 87

Slide 87 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5) val (name, age) = drew val (key, value) = Pair("session_id", "1") val (x, y, z) = Triple(0f, 0f, 1f)

Slide 88

Slide 88 text

data class User(val name: String, val age: Int) val drew = User("Drew", 5) val (name, age) = drew val (key, value) = Pair("session_id", "1") val (x, y, z) = Triple(0f, 0f, 1f)

Slide 89

Slide 89 text

enum class Result { SUCCESS, ERROR, }

Slide 90

Slide 90 text

enum class Result { SUCCESS, ERROR(val exception: Exception), }

Slide 91

Slide 91 text

sealed class Result { class Success : Result() class Error : Result() }

Slide 92

Slide 92 text

sealed class Result { class Success : Result() class Error : Result() }

Slide 93

Slide 93 text

sealed class Result { class Success : Result() class Error : Result() }

Slide 94

Slide 94 text

sealed class Result { class Success : Result() class Error : Result() }

Slide 95

Slide 95 text

sealed class Result { class Success : Result() class Error : Result() }

Slide 96

Slide 96 text

// otherfile.kt class ExternalResult : Result() sealed class Result { class Success : Result() class Error : Result() }

Slide 97

Slide 97 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() } // otherfile.kt class ExternalResult : Result()

Slide 98

Slide 98 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() }

Slide 99

Slide 99 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() } fun handleResult(result: Result) { when (result) { is Result.Success -> TODO("handle") is Result.Error -> TODO("handle") } }

Slide 100

Slide 100 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() } fun handleResult(result: Result) { when (result) { is Result.Success -> result.data is Result.Error -> result.exception.message } }

Slide 101

Slide 101 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() } fun handleResult(result: Result): String { return when (result) { is Result.Success -> result.data is Result.Error -> result.exception.message } }

Slide 102

Slide 102 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() object Cancelled : Result() } fun handleResult(result: Result): String { return when (result) { is Result.Success -> result.data is Result.Error -> result.exception.message } }

Slide 103

Slide 103 text

fun handleResult(result: Result): String { return when (result) { is Result.Success -> result.data is Result.Error -> result.exception.message Result.Cancelled -> "cancelled" } } sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() object Cancelled : Result() }

Slide 104

Slide 104 text

sealed class Result { data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() object Cancelled : Result() } fun handleResult(result: Result): String { return when (result) { is Result.Success -> result.data is Result.Error -> result.exception.message Result.Cancelled -> "cancelled" } }

Slide 105

Slide 105 text

sealed class Result data class Success(val data: T) : Result() data class Error(val exception: Exception) : Result() object Cancelled : Result() fun handleResult(result: Result): String { return when (result) { is Success -> result.data is Error -> result.exception.message Cancelled -> "cancelled" } }

Slide 106

Slide 106 text

class Preferences(databaseName: String) { private val db = SqlDatabase(databaseName) fun delete(name: String) { db.beginTransaction() try { db.execute("DELETE FROM user WHERE name = ?”) db.setTransactionSuccessful() } finally { db.endTransaction() } } }

Slide 107

Slide 107 text

class Preferences(databaseName: String) { private val db = SqlDatabase(databaseName) fun delete(name: String) { db.beginTransaction() try { db.execute("DELETE FROM user WHERE name = ?”) db.setTransactionSuccessful() } finally { db.endTransaction() } } }

Slide 108

Slide 108 text

class Preferences(databaseName: String) { private val db by lazy { SqlDatabase(databaseName) } fun delete(name: String) { db.beginTransaction() try { db.execute("DELETE FROM user WHERE name = ?”) db.setTransactionSuccessful() } finally { db.endTransaction() } } }

Slide 109

Slide 109 text

private val db by lazy { SqlDatabase(databaseName) }

Slide 110

Slide 110 text

private val db by lazy { SqlDatabase(databaseName) } var name by Delegates.observable("Drew") { prop, old, new !-> println("Name changed from $old to $new") }

Slide 111

Slide 111 text

private val db by lazy { SqlDatabase(databaseName) } var name by Delegates.observable("Drew") { prop, old, new !-> println("Name changed from $old to $new") } var address by Delegates.notNull()

Slide 112

Slide 112 text

private val db by lazy { SqlDatabase(databaseName) } var name by Delegates.observable("Drew") { prop, old, new !-> println("Name changed from $old to $new") } var address by Delegates.notNull() val labelView by bindView(R.id.label)

Slide 113

Slide 113 text

class Preferences(databaseName: String) { private val db by lazy { SqlDatabase(databaseName) } fun delete(name: String) { db.beginTransaction() try { db.execute("DELETE FROM user WHERE name = ?”) db.setTransactionSuccessful() } finally { db.endTransaction() } } } var name by Delegates.observable("Drew") { prop, old, new !-> println("Name changed from $old to $new") } var address by Delegates.notNull() val labelView by bindView(R.id.label)

Slide 114

Slide 114 text

class Preferences(databaseName: String) { private val db by lazy { SqlDatabase(databaseName) } fun delete(name: String) { db.beginTransaction() try { db.execute("DELETE FROM user WHERE name = ?”) db.setTransactionSuccessful() } finally { db.endTransaction() } } } val labelView by bindView(R.id.label)

Slide 115

Slide 115 text

fun delete(name: String) { db.beginTransaction() try { db.execute("DELETE FROM user WHERE name = ?") db.setTransactionSuccessful() } finally { db.endTransaction() } } class Preferences(databaseName: String) { private val db by lazy { SplDatabase(databaseName) } }

Slide 116

Slide 116 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 117

Slide 117 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 118

Slide 118 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 119

Slide 119 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 120

Slide 120 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 121

Slide 121 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { db.execute("DELETE FROM user WHERE name = ?") } }

Slide 122

Slide 122 text

fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { db.execute("DELETE FROM user WHERE name = ?") } }

Slide 123

Slide 123 text

fun SqlDatabase.transaction(func: (SqlDatabase) "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { db.execute("DELETE FROM user WHERE name = ?") } } .execute("DELETE FROM user WHERE name = ?")

Slide 124

Slide 124 text

fun SqlDatabase.transaction(func: (SqlDatabase) "-> Unit) { beginTransaction() try { func(this) setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { db.execute("DELETE FROM user WHERE name = ?") } } .execute("DELETE FROM user WHERE name = ?")

Slide 125

Slide 125 text

fun SqlDatabase.transaction(func: (SqlDatabase) "-> Unit) { beginTransaction() try { func(this) setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { it.execute("DELETE FROM user WHERE name = ?") } } .execute("DELETE FROM user WHERE name = ?")

Slide 126

Slide 126 text

fun SqlDatabase.transaction(func: (SqlDatabase) "-> Unit) { beginTransaction() try { func(this) setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { it.execute("DELETE FROM user WHERE name = ?") } } .execute("DELETE FROM user WHERE name = ?")

Slide 127

Slide 127 text

fun delete(name: String) { db.transaction { it.execute("DELETE FROM user WHERE name = ?") } } fun SqlDatabase.transaction(func: SqlDatabase.() "-> Unit) { beginTransaction() try { func(this) setTransactionSuccessful() } finally { endTransaction() } }

Slide 128

Slide 128 text

fun delete(name: String) { db.transaction { it.execute("DELETE FROM user WHERE name = ?") } } fun SqlDatabase.transaction(func: SqlDatabase.() "-> Unit) { beginTransaction() try { this.func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 129

Slide 129 text

fun delete(name: String) { db.transaction { it.execute("DELETE FROM user WHERE name = ?") } } fun SqlDatabase.transaction(func: SqlDatabase.() "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 130

Slide 130 text

fun delete(name: String) { db.transaction { execute("DELETE FROM user WHERE name = ?") } } fun SqlDatabase.transaction(func: SqlDatabase.() "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }

Slide 131

Slide 131 text

data class User(val name: String, val age: Int)

Slide 132

Slide 132 text

@Serializable data class User(val name: String, val age: Int)

Slide 133

Slide 133 text

@Serializable data class User(val name: String, val age: Int) val drew = User("Drew", 5) val jsonString = Json.encodeToString(drew)

Slide 134

Slide 134 text

@Serializable data class User(val name: String, val age: Int) val drew = User("Drew", 5) val jsonString = Json.encodeToString(drew) println(jsonString) "// {"name":"Drew","age":5}

Slide 135

Slide 135 text

@Serializable data class User(val name: String, val age: Int) val drew = User("Drew", 5) val jsonString = Json.encodeToString(drew) println(jsonString) "// {"name":"Drew","age":5} val drew = Json.decodeFromString(jsonString)

Slide 136

Slide 136 text

@Serializable data class User(val name: String, val age: Int) val drew = User("Drew", 5) val jsonString = Json.encodeToString(drew) println(jsonString) "// {"name":"Drew","age":5} val drew = Json.decodeFromString(jsonString) println(drew) "// User(name=Drew, age=5)

Slide 137

Slide 137 text

@Serializable data class User(val name: String, val age: Int) val drew = User("Drew", 5) val jsonString = Json.encodeToString(drew) println(jsonString) "// {"name":"Drew","age":5} val drew = Json.decodeFromString(jsonString) println(drew) "// User(name=Drew, age=5)

Slide 138

Slide 138 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 139

Slide 139 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 140

Slide 140 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 141

Slide 141 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 142

Slide 142 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 143

Slide 143 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 144

Slide 144 text

fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds) print(".") } } }

Slide 145

Slide 145 text

fun main() = runBlocking { repeat(100_000) { launch { delayAndPrint() } } } suspend fun delayAndPrint() { delay(1.seconds) print(".") }

Slide 146

Slide 146 text

fun main() = runBlocking { repeat(100_000) { launch { delayAndPrint() } } } suspend fun delayAndPrint() { delay(1.seconds) print(".") }

Slide 147

Slide 147 text

fun main() = runBlocking { repeat(100_000) { launch { delayAndPrint() } } } suspend fun delayAndPrint() { delay(1.seconds) print(".") }

Slide 148

Slide 148 text

suspend fun updateUserName() { Main { val user = Default { http.get("/api/user/1") } labelName.text = user.name } }

Slide 149

Slide 149 text

suspend fun updateUserName() { Main { val user = Default { http.get("/api/user/1") } labelName.text = user.name } }

Slide 150

Slide 150 text

suspend fun updateUserName() { Main { val user = Default { http.get("/api/user/1") } labelName.text = user.name } }

Slide 151

Slide 151 text

suspend fun updateUserName() { Main { val user = Default { http.get("/api/user/1") } labelName.text = user.name } }

Slide 152

Slide 152 text

suspend fun updateUserName() { Main { val user = Default { http.get("/api/user/1") } labelName.text = user.name } }

Slide 153

Slide 153 text

suspend fun updateUserName() { Main { val user = Default { http.get("/api/user/1") } labelName.text = user.name } }

Slide 154

Slide 154 text

suspend fun updateUserName() { Main { val user = try { Default { http.get("/api/user/1") } } catch (e: HttpResponseException) { e.printStacktrace() null } labelName.text = user"?.name } }

Slide 155

Slide 155 text

suspend fun updateUserName() { Main { val user = try { Default { http.get("/api/user/1") } } catch (e: HttpResponseException) { e.printStacktrace() null } labelName.text = user"?.name } }