scala - How is the "Any" class works with the "this" variable? -
please refer this, https://github.com/scala/scala/blob/v2.12.0-m1/src/library-aux/scala/any.scala
the abstract class uses "this" self reference equality test. far understand "this" not special scala. how "this" value handled in "any" ?
this special in scala. first of all, according lexical syntax section of language spec, this reserved keyword. see 6.5 , super part of spec precisely defines semantics of this keyword:
the expression
thiscan appear in statement part of template or compound type. stands object being defined innermost template or compound type enclosing reference. if compound type, type ofthiscompound type. if template of class or object definition simple namec, type ofthissame type ofc.this.
so in case of any class, this reference actual object method of equality called upon.
Comments
Post a Comment