I've defined a class that has a method in it that is trying to make use of a function with an implicit parameter in it. Unfortunately it's failing to compile
class Test {
def useImplicit(implicit a: Boolean) = a
def getAnswer() = if (useImplicit) println("yes") else println("no")
}
object Preferences {
implicit val yes = false
implicit val no = false
}
The problem is that when I go to compile the class to try and test it out I get the error
could not find implicit value for parameter a: Boolean
def getAnswer() = if (useImplicit) println("yes") else println("no")
I'm not exactly sure what is going on here. The reason for me trying it this way is I am ultimately wanting to overload hashCode and determine at runtime whether I should run my overloaded version or call the parent implementation. If this isn't possible I suppose I could make the class take an implicit