I'm confused about operator overloading. say I've got a
class Foo
and I'd like to override
Foo + String
and
String + Foo
, such that both return a
Foo
.
the first part is easy enough, just implement
operator fun plus(s: String): Foo
inside the definition of
class Foo
.
for the second part, attempting to add an extension function
operator fun String.plus(foo: Foo): Foo
makes kotlin complain that I'm shadowing
operator fun plus(other: Any?): String
is there a way around this (and should I even go that way)?