How can I overload a constructor in Scala with a function as a parameter

116 Views Asked by At

I am making a file searching program. This is contained in a "ParallelSearch" class. The signature is:

class ParallelSearch(condition: (Path, Int, String) => Boolean)

This is great and works. The user supplies a condition, that goes from a file path, a line number, and a string containing line content, to a Boolean. However, I would like to overload the constructor to allow the user to not specify file path or line number, and just search based on line contents. Like so:

def this(condition: String => Boolean) =
  {
    this((???): (Path, Int, String) => Boolean)
  }

What I'm not sure about is what to put where I have the ??? right now. I can answer any other questions that will make understanding easier. Any help is appreciated! Thanks!

0

There are 0 best solutions below