$30 off During Our Annual Pro Sale. View details »

Kotlin

Drew Carlson
November 16, 2020
15

 Kotlin

Drew Carlson

November 16, 2020
Tweet

Transcript

  1. None
  2. None
  3. None
  4. None
  5. None
  6. None
  7. val firstName: String = "Drew" val lastName: String? = null

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

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

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

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

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

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

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

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

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

    b }
  17. fun sum(a: Int, b: Int): Int = a + b

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

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

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

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

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

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

    fun stringOrDefault( subject: String?, default: String = "Default" ): String { return subject "?: default } stringOrDefault(name)
  24. 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")
  25. "// Java public class User { @NonNull public String getName()

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

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

    "// Java public class User { @NonNull public String getName() { "// ""... } public void setName(@NonNull String name) { "// ""... } }
  28. "// 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) { "// ""... } }
  29. "// 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) { "// ""... } }
  30. "// 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) { "// ""... } }
  31. "// 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) { "// ""... } }
  32. "// 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) { "// ""... } }
  33. "// Kotlin class User { var name = "Drew" }

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

  35. "// Java final User user = new User(); System.out.println("User: "

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

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

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

    + user.getName()); user.setName("Not Drew"); "// Kotlin class User { var name = "Drew" }
  39. "// Kotlin val user = User()

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

  41. var currentUser = User() currentUser = User() "// Kotlin val

    user = User() user = User()
  42. "// Kotlin "// file: com/app/locale.kt fun Locale.isLanguageEnglish(): Boolean { return

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

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

    language "== Locale.ENGLISH.language }
  45. "// 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") }
  46. "// 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") }
  47. "// 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") }
  48. "// 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 }
  49. "// 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);
  50. "// 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);
  51. val executor = Executors.newCachedThreadPool() executor.execute { println("from the background") }

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

  53. val worker = Worker() val executor = Executors.newCachedThreadPool() executor.execute(worker"::doWork) class

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

    Worker { fun doWork() { println("from the background") } }
  55. val work = { println("from the background") } val executor

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

    = Executors.newCachedThreadPool() executor.execute(work)
  57. fun <T> List<T>.filter(predicate: (T) "-> Boolean): List<T> { "// ""...

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

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

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

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

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

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

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

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

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

    } val drews = names.filter { it "== "Drew" } val names = listOf("Drew", "Ahsan", "Shivangi") val ahsans = names.filterTo(mutableSetOf()) { it == "Ahsan" }
  67. val drews = names.filter { it "== "Drew" } val

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

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

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

    destination = mutableListOf<T>() for (item in this) { if (predicate(item)) destination.add(item) } return destination } val destination = mutableListOf<String>() for (item in names) { if (item "== "Drew") destination.add(item) } val drews: List<String> = destination
  71. class User { val name = "drew" }

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

  73. class User(val name: String) { }

  74. class User(val name: String)

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

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

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

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

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

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

    $drew") Hello, User(name=Drew)
  81. data class User(val name: String, val age: Int) val drew

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

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

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

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

    = User("Drew", 5) val (name, age) = drew
  86. 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")
  87. 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)
  88. 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)
  89. enum class Result { SUCCESS, ERROR, }

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

  91. sealed class Result<T> { class Success<T> : Result<T>() class Error

    : Result<Nothing>() }
  92. sealed class Result<T> { class Success<T> : Result<T>() class Error

    : Result<Nothing>() }
  93. sealed class Result<T> { class Success<T> : Result<T>() class Error

    : Result<Nothing>() }
  94. sealed class Result<T> { class Success<T> : Result<T>() class Error

    : Result<Nothing>() }
  95. sealed class Result<T> { class Success<T> : Result<T>() class Error

    : Result<Nothing>() }
  96. // otherfile.kt class ExternalResult<out T : Any> : Result<T>() sealed

    class Result<T> { class Success<T> : Result<T>() class Error : Result<Nothing>() }
  97. sealed class Result<T> { data class Success<T>(val data: T) :

    Result<T>() data class Error(val exception: Exception) : Result<Nothing>() } // otherfile.kt class ExternalResult<out T : Any> : Result<T>()
  98. sealed class Result<T> { data class Success<T>(val data: T) :

    Result<T>() data class Error(val exception: Exception) : Result<Nothing>() }
  99. sealed class Result<T> { data class Success<T>(val data: T) :

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

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

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

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

    Result.Success -> result.data is Result.Error -> result.exception.message Result.Cancelled -> "cancelled" } } sealed class Result<T> { data class Success<T>(val data: T) : Result<T>() data class Error(val exception: Exception) : Result<Nothing>() object Cancelled : Result<Nothing>() }
  104. sealed class Result<T> { data class Success<T>(val data: T) :

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

    data class Error(val exception: Exception) : Result<Nothing>() object Cancelled : Result<Nothing>() fun handleResult(result: Result<String>): String { return when (result) { is Success -> result.data is Error -> result.exception.message Cancelled -> "cancelled" } }
  106. 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() } } }
  107. 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() } } }
  108. 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() } } }
  109. private val db by lazy { SqlDatabase(databaseName) }

  110. private val db by lazy { SqlDatabase(databaseName) } var name

    by Delegates.observable("Drew") { prop, old, new !-> println("Name changed from $old to $new") }
  111. 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<String>()
  112. 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<String>() val labelView by bindView<TextView>(R.id.label)
  113. 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<String>() val labelView by bindView<TextView>(R.id.label)
  114. 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<TextView>(R.id.label)
  115. 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) } }
  116. fun SqlDatabase.transaction(func: () "-> Unit) { beginTransaction() try { func()

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

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

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

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

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

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

    setTransactionSuccessful() } finally { endTransaction() } } fun delete(name: String) { db.transaction { db.execute("DELETE FROM user WHERE name = ?") } }
  123. 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 = ?")
  124. 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 = ?")
  125. 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 = ?")
  126. 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 = ?")
  127. 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() } }
  128. 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() } }
  129. 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() } }
  130. fun delete(name: String) { db.transaction { execute("DELETE FROM user WHERE

    name = ?") } } fun SqlDatabase.transaction(func: SqlDatabase.() "-> Unit) { beginTransaction() try { func() setTransactionSuccessful() } finally { endTransaction() } }
  131. data class User(val name: String, val age: Int)

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

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

    drew = User("Drew", 5) val jsonString = Json.encodeToString(drew)
  134. @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}
  135. @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<User>(jsonString)
  136. @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<User>(jsonString) println(drew) "// User(name=Drew, age=5)
  137. @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<User>(jsonString) println(drew) "// User(name=Drew, age=5)
  138. fun main() = runBlocking { repeat(100_000) { launch { delay(1.seconds)

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

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

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

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

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

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

    print(".") } } }
  145. fun main() = runBlocking { repeat(100_000) { launch { delayAndPrint()

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

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

    } } } suspend fun delayAndPrint() { delay(1.seconds) print(".") }
  148. suspend fun updateUserName() { Main { val user = Default

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

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

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

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

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

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

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

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