Something like this: ``` class Action(val field1: ...
# announcements
k
Something like this:
Copy code
class Action(val field1: String, val field2: String, closure: Action.() -> Unit) {
    private val _closure = closure
    val closure: () -> Unit = { this._closure() }
}

val myAction = Action("value1", "value2") { callAnotherFunctionHere(this) }
n
@karelpeeters Thanks, and please feel free to write it as you think it is more idiomatic Kotlin.
k
I would do something like this:
Copy code
class Action(
        val field1: String,
        val field2: String,
        private val closure: Action.() -> Unit
) {
    fun run() = this.closure()
}