Erik
06/01/2021, 7:28 PMWhen overriding your operator overloads, you can omit `operator`:(https://github.com/JetBrains/kotlin-web-site/blob/f3096d05fdfbc29ec4a704f42112028cdc7f48b7/docs/topics/operator-overloading.md#L15-L21) Why? Isn't it a bit implicit to override an operator, but not mark it as being an operator? I mean: if you'd override an operator without the keyword, you'd have to check the super declaration whether or not it actually is an operator. In turn, that can be an override without the keyword, all the way to the topmost declaration. I guess this is a non-issue because you wouldn't do this often. Without the explicit keyword it might be difficult to discover that a function is actually an
operator
, so that you could use the operator syntax instead of a regular function invocation (e.g. obj.invoke()
vs obj()
).Nir
06/01/2021, 7:32 PMErik
06/01/2021, 7:34 PMNir
06/01/2021, 7:34 PMNir
06/01/2021, 7:35 PMoperator
work the way it works everywhere else, isn't really acceptableNir
06/01/2021, 7:35 PMNir
06/01/2021, 7:36 PMErik
06/01/2021, 7:36 PMoverride
, which is an improvement w.r.t. e.g. Java in which ☕ @Override
is optional 🤦♂️Nir
06/01/2021, 7:42 PMNir
06/01/2021, 7:43 PMErik
06/01/2021, 7:43 PMErik
06/01/2021, 7:44 PMpublic
keyword being the default, and therefore optionalErik
06/01/2021, 7:47 PMpublic
and Unit
return types become non-optional? Does that also require the operator
keyword on overrides?Nir
06/01/2021, 7:55 PMPaul Griffith
06/01/2021, 8:20 PMJsonObject
has a get(key: String)
method, which you can directly use from Kotlin in square brackets without needing to define an extension operator fun. I do think it'd be nice to be explicit in (some?) Kotlin contexts, thoughTyler Hodgkins
06/01/2021, 8:44 PM