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

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -