i have class written expects given option[(e) => long]
:
class whatever[e] (sizefunction: option[(e) => long])
when try , instantiate function (e) => int
:
val sizefunction = (a: string) => a.length new whatever[string](some(sizefunction))
i compilation error:
type mismatch; found : string => int required: string => long
shouldnt string => int
"satisfy" string => long
due widening?
keep in mind string => int type in , of itself. string => long different type. important programs , not important others, in example. dangerous compiler make assumptions , not call out type mismatches because possibly widen 1 part of function type. if care can define sizefunction string => number.
Comments
Post a Comment