上一页 1 ··· 174 175 176 177 178 179 180 181 182 ··· 477 下一页
摘要: fun getColorType() : String { val color = getUpperFavoriteColor() return when (color) { "" -> "empty" "RED", "GREEN", "BLUE" -> "rgb" else -> "other" 阅读全文
posted @ 2020-10-28 20:58 Zhentiw 阅读(139) 评论(0) 推荐(0)
摘要: Let function is another way to solve null problem in kotlin. When you have such problem: var favoriteColor: String? = null...... return if f(avoriteCo 阅读全文
posted @ 2020-10-28 20:54 Zhentiw 阅读(80) 评论(0) 推荐(0)
摘要: In Javascript, we have: return age null ? -1 : age In kotlin, we can do the same thing with a better / simpler syntax: val safeAge: Int get() = age ?: 阅读全文
posted @ 2020-10-28 20:37 Zhentiw 阅读(139) 评论(0) 推荐(0)
摘要: For data class, you can get 'copy' method, and also destructing: data class Customer (val name: String, val address: String, var age: Int) { // if we 阅读全文
posted @ 2020-10-27 17:04 Zhentiw 阅读(108) 评论(0) 推荐(0)
摘要: // Shorter version class AnotherAlternativeCustomer (val name: String,var age: Int, val address: String = "") { var approvered: Boolean = false set(va 阅读全文
posted @ 2020-10-27 16:49 Zhentiw 阅读(135) 评论(0) 推荐(0)
摘要: package com.rsk class Customer (val name: String, val address: String, var age: Int) { // if we don't want to pass in the address constructor(name: St 阅读全文
posted @ 2020-10-27 16:42 Zhentiw 阅读(152) 评论(0) 推荐(0)
摘要: In this lesson, we use CSS transforms to create configurable 3D cuboids. Using CSS transforms in combination with scoped CSS variables, we are able to 阅读全文
posted @ 2020-10-26 21:37 Zhentiw 阅读(198) 评论(0) 推荐(0)
摘要: In this lesson, we explore how you can use CSS variables almost like Boolean values in combination with calc(). By setting a variable to 1 or 0 and th 阅读全文
posted @ 2020-10-26 21:29 Zhentiw 阅读(154) 评论(0) 推荐(0)
摘要: val randomNumber = Random().nextInt(3) if (randomNumber is BigDecimal) { result = result.add(BigDecimal(36)) } If you use type check, then 'result' is 阅读全文
posted @ 2020-10-26 18:36 Zhentiw 阅读(86) 评论(0) 推荐(0)
摘要: Let's see following code: println(colors.reduce { acc, curr -> "$acc, $curr" }) // red, blue, green, black val myMap = mapOf(1 to "one", 2 to "two", 3 阅读全文
posted @ 2020-10-26 16:22 Zhentiw 阅读(136) 评论(0) 推荐(0)
上一页 1 ··· 174 175 176 177 178 179 180 181 182 ··· 477 下一页