the following code works:
def bbb(v: double => unit)(a: double): unit = v(a) bbb{v: double => v == 0 }(5) bbb{v: double => array(v) }(5)
but if overload bbb
follows, doesn't work unless manually assign type signature first bbb
call:
def bbb(v: double => unit)(a: double): unit = v(a) def bbb(v: double => array[double])(a: double): array[double] = v(a) bbb{v: double => v == 0 }(5) // bbb{(v => v == 0):(double => unit)}(5) bbb{v: double => array(v) }(5)
i think related implicit conversions. in first case, when have definition results in unit, though results such boolean or array, implicit conversion unit triggered returning expected unit.
when overload, implicit conversion no longer applied, overloading resolution mechanism instead. can find how works in more detail in scala language specification
Comments
Post a Comment