Last active
December 17, 2015 02:38
-
-
Save ryanlecompte/5537190 to your computer and use it in GitHub Desktop.
scala self referential types
This file contains hidden or 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
// 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