Help to understand, there is a code:

button.addListener(object : InputListener() { override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean { object : Dialog("window") { init { ... } } .show() .addListener(object : InputListener() { override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean { if (...) { ??-->> dialog.hide() } return true } }); } } 

How to write the dialog.hide() line correctly in it to refer to the created object? (Dialog ("window"))

    1 answer 1

    No It is necessary to refactor the code so that there is a link to a non-mutable object.
    Type of such:

      val dialog = object : Dialog("window") { init { ... } } dialog.show() dialog.addListener(object : InputListener() { override fun touchDown(event: InputEvent?, x: Float, y: Float, pointer: Int, button: Int): Boolean { if (...) { dialog.hide() } return true } })