Are top level variables initialized differently in...
# multiplatform
p
Are top level variables initialized differently in kotlin native? I have code that runs on jvm fine, but in native I get a bad_access for a val. Given: class A(private var b: B) { fun foo() { b.bar() } } val b = B() val a = A(b) I will get a bad_access (null pointer) on the instance of b when calling b.bar() in foo(). Changing a to use
by lazy
fixes the problem.
o
Are all declarations in the same file?
p
no
o
so it’s where problem came from - there’s no order guarantees between files
p
thank you for clarifying