Skip to content

Instantly share code, notes, and snippets.

@seraphr
Created November 29, 2013 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seraphr/7711732 to your computer and use it in GitHub Desktop.
Save seraphr/7711732 to your computer and use it in GitHub Desktop.
scala 構造的部分型
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