Created
November 12, 2014 09:18
-
-
Save salomvary/aa16564410e8d1fad7e4 to your computer and use it in GitHub Desktop.
Scala type ascription
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
scala> class Foo | |
defined class Foo | |
scala> class Bar extends Foo | |
defined class Bar | |
scala> new Foo | |
res6: Foo = Foo@3ace5360 | |
scala> new Bar | |
res8: Bar = Bar@6506fe2b | |
scala> new Bar: Foo | |
res9: Foo = Bar@15c673a9 | |
scala> new Bar: String | |
<console>:10: error: type mismatch; | |
found : Bar | |
required: String | |
new Bar: String | |
^ | |
scala> new Bar: Any | |
res11: Any = Bar@50eb8271 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment