function - Scala Function1 Generic parameter and return type -
lets want store map[string, function1] parameter , return type of function1 can vary. how go storing function1[string, string] , function1[int, int] in same map.
i've tried function1[anyref, anyref] function1[string, string] isn't function1[anyref, anyref] fails compile.
if have 2 possible value types, can wrap values in either:
val m = map[string, either[int => int, string => string]]() if want store more 2 different types, create own wrapper, or use coproduct shapeless.
Comments
Post a Comment