Self Type in Scala
Introduction
Self Types are a way of specifying the dependencies for a class/trait in Scala. Using this, the compiler can enforce to provide the required dependencies while instances are created. This is widely used in Scala, especially in cake patte...
yadukrishnan.live3 min read
Nick F
Implementation Specific
Have you used this in the wild? It seems interesting, but not sure when I would use it. Perhaps if I don't control the
Vehicletrait, but I want to extend it? But Scala has Extension Methods to do this as well. When should I use one or the other? I haven't had to use Extension Methods either. Perhaps this is more for building Libraries and not Applications?This remind me a lot of
var that = this;in JavaScript haha, brings me back. :-)