Scala LanguageSelf types


Syntax

  • trait Type { selfId => /other members can refer to selfId in case this means something/ }
  • trait Type { selfId: OtherType => /* other members can use selfId and it will be of type OtherType */
  • trait Type { selfId: OtherType1 with OtherType2 => /* selfId is of type OtherType1 and OtherType2 */

Remarks

Often used with the cake pattern.