https://kotlinlang.org logo
d

David Smith

06/28/2021, 4:56 PM
I’m having a weird error that I don’t understand. I have a kotlin “type-safe builder” for some html and in it I have 2 child elements, one of which is inside a
when
Copy code
div {
  h1 { ... }
  when (x) {
    A -> +"text"
    B -> div { ... }
  }
}
The actual model that this produces reverses the order of the
h1
and the other child. The order is correct if I have the same but without the
with
construct. The same issue happens with
if
. Am I misunderstanding something about execution order in lambdas or something?
c

CLOVIS

06/28/2021, 9:14 PM
Is this
kotlinx.html
? The only reason that I could see causing this is an error in the implementation of the DSL, but that really shouldn't happen.
I'm using Kotlin React and that definitely doesn't happen (I use lambdas &
when
all the time)
d

David Smith

06/29/2021, 1:31 PM
indeed, the issue was unrelated and I just hadn’t been systematic enough in chasing down the issue 😞 The when had caused some unforeseen logical differences which should have been obvious to me
3 Views