Created
November 29, 2013 20:41
-
-
Save seraphr/7711732 to your computer and use it in GitHub Desktop.
scala 構造的部分型
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
trait Hoge{def hoge: String} | |
def h(a: Hoge) = a.hoge | |
val hogeInstance: Hoge = new Hoge{def hoge = "hoge"} | |
val hogeLikeInstance: {def hoge: String} = new {def hoge = "fuga"} | |
h(hogeInstance) // OK | |
h(hogeLikeInstance) // NG | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment