drawable.dsl icon indicating copy to clipboard operation
drawable.dsl copied to clipboard

用apply优化一下更优雅,不需要写return this

Open rainfoam opened this issue 1 year ago • 1 comments

fun corners(builder: CornersBuilder.() -> Unit): ShapeBuilder { cornersBuilder.builder() return this }

改成:

fun corners(builder: CornersBuilder.() -> Unit): ShapeBuilder = apply { cornersBuilder.builder() }

kotlin建造者模式都这样写

rainfoam avatar Oct 13 '22 06:10 rainfoam