简体   繁体   中英

What does -= operator mean in scala def context

I discovered the below odd def definition syntax in Kafka source code . Can somebody help me understand this syntax as I am unable to find in scala documents. The first def definition works but the second one does not work

  private def test_=(x: Int) {

  }

  private def test=(x: Int) {

  }

It isn't an operator. There is just a special rule that if you have a method with a name ending in _= and a single argument, and a no-argument method with the same name without _= (in this case def test = ... ), then Scala will understand foo.test = ... as the foo.test_=(...) call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM