Scala Language Self types

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any Scala Language Question?