How can I require a scope for a function to be used in?

So, I am creating a app and have the following scenario in a canvas onDraw callback:

fun App() { var state by remember { mutableStateOf(EcosymstemState()) } Canvas(modifier = Modifier.fillMaxSize().background(Color.Black)) { state.population.forEach { it.update() it.draw(this) } } } 

state.population is a Set of Beings. Being is as follow:

class Being { fun update() { } fun draw(drawScope: DrawScope) = with(drawScope) { drawCircle(Color.Blue) } } 

Is there a better way of writing my function to specify I want it to be used inside a DrawScope? So I would like to not need to write it.draw(this), but to be able to use just it.draw()

There is nothing special about what I want, it is just code styling (and I am almost sure there is a way, at least I’ve seen something similar some time ago.

submitted by /u/Nolear
[link] [comments]