-
-
Save KirinDave/1162732 to your computer and use it in GitHub Desktop.
cyclic definitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object A1 { lazy val X = B1.Y } | |
object B1 { lazy val Y: Int = A1.X } | |
println("Executes safely unless you try and evaluate A1.X or B1.Y because they have no definition.") | |
object ABase { val X = 1 } | |
object A2 { lazy val X = B2.Y+1 } | |
object B2 { lazy val Y :Int = ABase.X*2 } | |
println("Even this could cause problems, but lazy helps. A2.X = " + A2.X.toString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment