<Can I access variable definitions in one block fr...
# forum
r
Can I access variable definitions in one block from another one? There is this “arrange-act-assert” pattern for tests, and I asked myself if it would be possible to write a DSL separating the three phases, something like arrange { val x = 23 val y = 15 }.act { x + y }.asserting { assertThat(it).equals(38) } I found no way to get x and y variables from the first block into scope of the second. Is this even possible? This might not be the most useful example, but I think the ability to pass around variable references captured in a block...