I have a problem with an implicit function imported from a package.
I have a class that uses Regex to search for something in the text. I would like to use it like:
val pattern = "some pattern here".r pattern findSomethingIn some_text
To do this, I define an implicit finction to convert the pattern to a Wrapper wrapper that contains the findSomethingIn function
package mypackage { class Wrapper ( val pattern: Regex ) { def findSomethingIn( text: String ): Something = ... } object Wrapper { implicit def regex2Something( pat: Regex ): Wrapper = new Wrapper( pat ) } }
if i use it like
import mypackage._ Wrapper.regex2Something( pattern ) findSomethingIn some_text
it works. whereas if i use
pattern findSomethingIn some_text
I get
value findPriceIn is not a member of scala.util.amtching.Regex
so the implicit conversion doesnβt work here ... What is the problem?
source share