scala - Why put a generic type next to a function? -
when @ scala libraries see code this. why put test [a] .
def test[a](block : int => unit) : unit = { block(10) } test { u => println(u) } this valid suppose. runs same way.
def test(block : int => unit) : unit = { block(10) } i've been curious reasoning(or design pattern) behind it. thanks.
the type parameter a makes no sense here because not used.
def test[a](block: int => a): = block(10) here a specifies return type.
Comments
Post a Comment