Skip to content

Instantly share code, notes, and snippets.

@ryanlecompte
Last active December 17, 2015 02:38
Show Gist options
  • Save ryanlecompte/5537190 to your computer and use it in GitHub Desktop.
Save ryanlecompte/5537190 to your computer and use it in GitHub Desktop.
scala self referential types
// based on http://blog.jessitron.com/2013/02/scala-talking-about-yourself.html
trait Foo[A <: Foo[A]] { self: A =>
def |[B](x: B): (A, B) = (this, x)
}
case class Text(t: String) extends Foo[Text]
Text("scala is cool")|100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment