Object and set() put() method


#1

It looks like it isn't possible with an object to do that :

{code}
object P {
  fun set(key:String, value:String) {
  // do something there
  }
  fun put(key:String, value:String) {
  // do something there
  }
}

fun test() {
  P[“this”] = “doesn’t work”
}
{code}

Is this a bug ? by design ? or am I doing something stupid ?


#2

Looks like a bug. getter works, and setter works if assigned to a variable. I've created an issue: https://youtrack.jetbrains.com/issue/KT-6621