i'm new to scala and trying some handson exercises .
i'm trying to use implicits by placing implicits in a companion object . however , the compiler doesn't detect implicit unless it is used .
class ImplicitTest {
import Implicits.implicitInt;
println(implicitInt)
def implicitm1(implicit i : Int) = 1
println(implicitm1)
}
object Implicits {
implicit val implicitInt = 1
}
This compiles fine . However if i comment out the third line
\\println(implicitInt)`
then i get a compile-time errors on
println(implicitm1)`
which says
could not find implicit value for parameter i:Int`
not enough arguments for method implicit m1(implicit i:Int) . Unspecified value parameter i`
what did i do wrong here ?
Thanks in advance