Skip to content

Instantly share code, notes, and snippets.

@kknd22
Last active December 22, 2016 15:41
Show Gist options
  • Save kknd22/f2b9746f92cd76554dcb3b77a17b8467 to your computer and use it in GitHub Desktop.
Save kknd22/f2b9746f92cd76554dcb3b77a17b8467 to your computer and use it in GitHub Desktop.
scala self
http://www.scala-lang.org/old/node/8194.html
http://stackoverflow.com/questions/4017357/difference-between-this-and-self-in-self-type-annotations
3 forms:
trait A {self: B =>..}
trait A {self =>..}
trait A {this: B =>..}
trait A {self: B =>..} is the most useful one. used primary for mixins.
'A' implements a small groups of very specific operations for very generic type. 'B' could be potentially implements another a small group.
'A' always used in mixed with 'B' (or its sub types) to form a greater sets of operations
trait A {self =>..}
useful in nested class definitions
trait A {this: B =>..}
same as #1 without any alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment