how would I define a `fun <T>` where `<T&...
# announcements
d
how would I define a
fun <T>
where
<T>
is one of 2 or more unrelated classes? for example:
<T>
can be
<String>
or
Map<*,*>
but nothing else
a
if the map contains normal execution result and the string contains some error message or viceversa, you can use Either from funktionale https://github.com/MarioAriasC/funKTionale/wiki/Either
d
interesting, thanks
m
or
fun<T> funName() where T : String, T : Map<*,*>
k
@menegatti That won't work, it requires
T
to extend both
String
and
Map
, which is impossible since
String
is a final class.
m
good one, I completely missed that point
k
how about two overloads?
f
How about
T : someSealedClass
?