Last active
December 12, 2015 09:29
-
-
Save lazyval/4751726 to your computer and use it in GitHub Desktop.
Possible bug during object init (or perhaps scala just throws away code that produces only side effects)
This file contains hidden or 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 Foo { | |
| val bar = { println("bar"); 42 } | |
| } | |
| object Foo2 { | |
| val bar = { println("bar") } | |
| } | |
| // scala> Foo.bar | |
| // bar | |
| // res0: Int = 42 | |
| // | |
| // scala> Foo2.bar | |
| // | |
| // scala> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected "bar" to be printed in both cases. Got this behaviour on 2.9.2 final