Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created August 26, 2011 14:55
Show Gist options
  • Save kmizu/1173588 to your computer and use it in GitHub Desktop.
Save kmizu/1173588 to your computer and use it in GitHub Desktop.
Welcome to Scala version 2.9.0.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.
scala> trait scope {
| class A extends AnyRef with Z {
| def aaa() = zzz2()
| def aaa2() = 100
| }
| trait Z {self: A =>
| def zzz() = aaa2()
| def zzz2() = 22
| }
| }
defined trait scope
scala> object M extends scope {
| def main(args: Array[String]) {
| val a = new A
| println(a.aaa() + a.zzz())
| }
| }
defined module M
scala> M.main(Array())
122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment