我有一个方法,每次都必须传入一个固定的对象 paint
,因为这个函数会被频繁调用,所以我不能在内联函数中创建对象。
inline fun Canvas.drawPoint( point: PointF, paint: Paint) { drawPoint(point.x, point.y, paint) }
但是我很多地方都会调用这个方法。
//(Canvas.apply(..,..)) drawPoint(pointA, pointPaint) drawPoint(pointB, pointPaint) drawPoint(pointC, pointPaint) drawPoint(pointD, pointPaint)
可以看到每次都会传入一个pointPaint
对象。
所以我在想有没有类似这样一个功能
//(Canvas.apply(..,..)) bind(pointPaint) drawPoint(pointA) drawPoint(pointB) drawPoint(pointC) drawPoint(pointD)
蝴蝶刀刀
萧十郎