While scala compiler look for implicit, takes following precedence
1) First look in current scope
2) Looks into import
3) Looks into wildcard import
4) Find in companion Object
If found two matching implicit in above scope compiler will give error.
1) First look in current scope
implicit val n: Int = 4
def add(x: Int)(implicit y: Int) = x+y 2) Looks into import
3) Looks into wildcard import
4) Find in companion Object
If found two matching implicit in above scope compiler will give error.
No comments:
Post a Comment