简体   繁体   中英

Scope of implicit functions in objects with the same name as the class in scala

The question is simple: in Scala, are the implicit function definitions of object A in the scope of class A? Or do I have to explicitly use import A._ to get access to the implicit functions?

The question is simple: in Scala, are the implicit function definitions of object A in the scope of class A?

No, you have to import them (same as non-implicit members of object A ). But of course, any implicit conversions from or to A are always searched in the companion object, if there are none in scope.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM