上一页 1 ··· 160 161 162 163 164 165 166 167 168 ··· 486 下一页
摘要: In Java, when you write code in try(...), if exception throw, the resource will be closed automactially: This is not necessary in Kotlin fun printFile 阅读全文
posted @ 2020-10-30 01:39 Zhentiw 阅读(164) 评论(0) 推荐(0)
摘要: In java, it requires you to handle the exception when you declaring and using the code: public class BoringJavaCode { public static Double divide(int 阅读全文
posted @ 2020-10-30 01:37 Zhentiw 阅读(158) 评论(0) 推荐(0)
摘要: List is not mutable, when you want to add data into list, you can do is: "adding data to a mutableList", then return a immutable list by calling toLis 阅读全文
posted @ 2020-10-30 01:20 Zhentiw 阅读(379) 评论(0) 推荐(0)
摘要: The part pseudo class allows consumers of a web component to manipulate certain key elements inside the Shadow DOM. In this lesson we will explore two 阅读全文
posted @ 2020-10-29 22:04 Zhentiw 阅读(114) 评论(0) 推荐(0)
摘要: document.getElementById("app").innerHTML = ` <h1>Hello Parcel!</h1> <div> <button id="plus">+</button> <button id="mius">-</button> </div> `; const ad 阅读全文
posted @ 2020-10-29 01:34 Zhentiw 阅读(124) 评论(0) 推荐(0)
摘要: (0..9).forEach(::println) (9 downTo 0).forEach(::println) (0 until 9).forEach(::println) // 0 to 8 (0..9 step 2).forEach(::println) ('A'..'F').forEach 阅读全文
posted @ 2020-10-29 01:04 Zhentiw 阅读(82) 评论(0) 推荐(0)
摘要: fun getColorType() : String { val color = getUpperFavoriteColor() return when (color) { "" -> "empty" "RED", "GREEN", "BLUE" -> "rgb" else -> "other" 阅读全文
posted @ 2020-10-28 20:58 Zhentiw 阅读(123) 评论(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 阅读(57) 评论(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 阅读(117) 评论(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 阅读(85) 评论(0) 推荐(0)
上一页 1 ··· 160 161 162 163 164 165 166 167 168 ··· 486 下一页