Explicit self-references with no type / difference with ''this''

前端 未结 2 1307
盖世英雄少女心
盖世英雄少女心 2020-11-30 04:24

I understand the use for explicitly typed self-references:

trait T {
  self : T2 =>
  ...
}

In the body, self is an alias f

2条回答
  •  無奈伤痛
    2020-11-30 05:18

    In that case self is a another way of saying this.

    If you happen to have an inner class, however, this inside the inner class would be the inner class, and self would be the container class.

    That's the only difference AFAIK

提交回复
热议问题