This and that keywords - difference

#1

I have searched Scala doc and do not see any explanation on “that” keyword.
if any one have a good explanation/example on how/where to use “this/that” keyword would be very usable.

#2

that is not a keyword. It’s just a name some people like to use for a variable that refers to an instance of the current class.

class A {
  def isTheSameAs(that: A) = this == that
}
2 Likes
#3

Thank you very much Jasper-M.

#5

Don’t withdraw the question. It might be useful to someone else having the same question. Experts easily forget which things are confusing to beginners.

1 Like