官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 汝州市| 保山市| 七台河市| 当阳市| 会东县| 东方市| 临高县| 当阳市| 汉中市| 卢湾区| 砚山县| 合水县| 凤冈县| 上虞市| 岑溪市| 琼海市| 延边| 温宿县| 大关县| 陆川县| 社旗县| 大竹县| 喀什市| 班戈县| 罗江县| 浦城县| 德惠市| 奎屯市| 株洲县| 邯郸县| 宜宾县| 阿尔山市| 右玉县| 如东县| 尼玛县| 奎屯市| 长武县| 和林格尔县| 弥渡县| 卫辉市| 松滋市|