Created
October 11, 2016 23:01
-
-
Save Allan-Gong/5b229b4117378b4559abdddc7a485c93 to your computer and use it in GitHub Desktop.
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
trait Foo { def bar: Int } | |
object F1 extends Foo { def bar = util.Random.nextInt(33) } // ok | |
class F2(val bar: Int) extends Foo // ok | |
object F3 extends Foo { | |
lazy val bar = { // ok | |
Thread.sleep(5000) // really heavy number crunching | |
42 | |
} | |
} | |
// If you had | |
trait Foo { val bar: Int } | |
// You wouldn't be able to define F1 or F3. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment