Eric O'Connell
07/12/2019, 7:57 PMfun <T, R> Optional<T>.mapDefault(default: R, mapper: (T) -> R): R
and call it with a default of a subtype of a sealed class
e.g. maybeThing.mapDefault(Action.NoFoo) { thing -> Action.Foo }
then this fails type checking because R
in mapDefault
is bound to Action.NoFoo
— is there a good way around this besides calling maybeThing.mapDefault<Thing, Action>
?streetsofboston
07/12/2019, 7:59 PMfun <T, S, D : S, R : S> Optional<T>.mapDefault(default: D, mapper: (T) -> R): S
Eric O'Connell
07/12/2019, 8:06 PM