Replies: 4 comments
-
I'm not sure what you mean. This utility is already available in |
Beta Was this translation helpful? Give feedback.
-
i say change that //me
inline fun <T : Batch> T.use(func: T.() -> Unit) {
begin()
func() // <--
end()
}
//you
inline fun <B : Batch> B.use(action: (B) -> Unit) {
begin()
action(this) // <--
end()
} on using // you
batch.use { it ->
it.draw(somthing, 0, 0)
it.draw(somthing, 0, 0)
it.draw(somthing, 0, 0)
player.draw(it)
obj.draw(it)
}
//me
batch.use { it ->
draw(somthing, 0, 0)
draw(somthing, 0, 0)
draw(somthing, 0, 0)
player.draw(this)
obj.draw(this)
} I do not want to do a job twice it`s just little better |
Beta Was this translation helpful? Give feedback.
-
That's deliberate, as you usually don't want to overshadow batch.use {
batch.draw(something, 0, 0)
batch.draw(something, 0, 0)
batch.draw(something, 0, 0)
player.draw(batch)
obj.draw(batch)
} Besides, the original |
Beta Was this translation helpful? Give feedback.
-
way dont use like this
and on using
Beta Was this translation helpful? Give feedback.
All reactions