I have a class that takes an implicit parameter that is used by functions called inside the class of methods. I want to be able to either override this implicit parameter, or, alternatively, the implicit argument will be copied from its source. As an example:
def someMethod()(implicit p: List[Int]) {
The behavior I want is that someMethod () gets an implicit parameter, which is some modified version of x, which was an implicit parameter of the class. I want to be able to either mutate x without changing it in order to pass it to constructor A, or otherwise override it with a new value of my choice. Both approaches do not seem to work. That is, it does not copy the list in the first case, and the compiler finds an ambiguous implicit value for the last case. Is there any way to do this?
I understand that I can override the implicit value in go (), but this is not a good choice in my case, because this class is subclassed many times, and I would like to handle this implicit change only in the base class, therefore, it is not necessary to go to the constructor , but it must be in a method other than go ().
source share