Yes. I guess I'll have to define some other interf...
# getting-started
m
Yes. I guess I'll have to define some other interface, or else Any will be acceptable.
m
If everything you want in that method is to print an object that's passed to it, then
Any
will solve your problem. You can call
toString
on
Any
object which is every object you create in Kotlin. And then, if you pass it a type that overrides basic implementation of
toString
(custom
data class
, built-in
data class
, custom
class
that overrides
toString
, ...), you'll get that exact output. If you pass it some other object, it will fallback and print just it's reference alongside it's class name.