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

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -