Why is there only 1 type parameter in scala list flatmap parameter signature -


why flatmap list takes b type parameter

def flatmap[b](f: (a) => u[b]): u[b] 

instead of

def flatmap[a, b](f: (a) => u[b]): u[b] 

because a deduced type parameter defined on list:

sealed abstract class list[+a] 

and since flatmap defined each element of type a in list, there's no need explicitly declare it.


Comments

Popular posts from this blog

ruby on rails - ActiveRecord order not working -

java - AEM: 403 Forbidden occurs when call a Post servlet -

How to embed a map into Netlogo using GIS extension? -