There is no problems in this code, but you should define htrav
in HeadLast
companion object or import it manually:
scala> (new DoStuff).stuff(List(1, 2, 3), 3)
<console>:11: error: could not find implicit value for parameter hl: HeadLast[Int,List[Int]]
(new DoStuff).stuff(List(1, 2, 3), 3)
^
scala> import DoStuff._
import DoStuff._
scala> (new DoStuff).stuff(List(1, 2, 3), 3)
res0: Boolean = true
Compiler will not search in DoStuff
object for this implicit HeadLast
.
See also: Where does Scala look for implicits?