you could try something like that, not thread safe...
# announcements
v
you could try something like that, not thread safe though and requires passing some sort of unique id which then is also not ideal
Copy code
private val onesies = HashSet<String>()

fun once(id: String, block: () -> Unit) {
    if (!onesies.contains(id)) {
        onesies += id
        block()
    }
}

fun twice() {
    once("my_block") {
        println ("stuff")
    }
}

fun main(args: Array<String>) {
    twice()
    twice()
}