- Kotlin Standard Library Cookbook
- Samuel Urbanowicz
- 135字
- 2021-07-23 19:05:57
There's more...
If you want only some of the lambdas passed to the function to be inlined, you can mark some of the function parameters with the noinline modifier:
inline fun foo(inlined: () -> Unit, noinline notInlined: () -> Unit) {
// ...
}
Kotlin also allows declaring inline class properties. The inline modifier can be used with getter and setter methods of properties that don't have a backing field. For example:
val foo: Foo
inline get() = Foo()
var bar: Bar
get() = ...
inline set(v) { ... }
We can also annotate an entire property:
inline var bar: Bar
get() = ...
set(v) { ... }
As a result, the inlined getters and setters are going to be represented in the same way as the regular inline functions.
推薦閱讀
- Spring Boot 2實戰之旅
- Java Web開發之道
- Visual FoxPro 程序設計
- Java Web程序設計
- Python數據挖掘與機器學習實戰
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(高級進階篇)
- Java項目實戰精編
- IBM Cognos Business Intelligence 10.1 Dashboarding cookbook
- MySQL入門很輕松(微課超值版)
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- OpenStack Networking Essentials
- Web App Testing Using Knockout.JS
- 深入理解BootLoader
- MySQL 8從零開始學(視頻教學版)
- Spring Boot從入門到實戰