zhengruifeng commented on PR #54068:
URL: https://github.com/apache/spark/pull/54068#issuecomment-3821620846
A simple example to illustrate the initialization order issue:
```scala
scala> trait A {
val a: Int
val b = a + 1
}
// defined trait A
scala> class B extends A { override val a: Int = 2 }
// defined class B
scala> val b = new B
val b: B = B@1492c9d
scala> b.b
val res0: Int = 1
scala> trait A {
def a: Int
val b = a + 1
}
// defined trait A
scala>
scala> class B extends A { override val a: Int = 2 }
// defined class B
scala> val b = new B
val b: B = B@3d741969
scala> b.b
val res1: Int = 1
scala>
scala> trait A {
def a: Int
def b = a + 1
}
// defined trait A
scala> class B extends A { override val a: Int = 2 }
// defined class B
scala> val b = new B
val b: B = B@5fca8642
scala> b.b
val res2: Int = 3
```
see https://docs.scala-lang.org/tutorials/FAQ/initialization-order.html for
more details
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]