In fact, there are more type names between val and object .
You know, an object in Scala is something like a singleton in Java.
You might have thought that both string and BooleanShow are in an object not a class , so they make no difference, but that is not the case.
They are val and object no matter what.
Try this in the Scala REPL.
trait Show[T] { def show(obj: T): String } object Show { println("!! Show created") implicit val string = new Show[String] { println("!! string created") def show(obj: String): String = obj } implicit object BooleanShow extends Show[Boolean] { println("!!BooleanShow created") def show(obj: Boolean): String = obj.toString } }
If only the definition is executed, then no println is executed after Show is a single. It has not been created yet.
Then do a Show in the Scala REPL.
scala> Show !! Show created !! string created res0: Show.type = Show$@35afff3b
You see, println in Show and Show.string were called, but in Show.BooleanShow not.
You can run Show.BooleanShow further in the Scala REPL.
scala> Show.BooleanShow !!BooleanShow created res1: Show.BooleanShow.type = Show$BooleanShow$@18e419c5
Show.BooleanShow was finally initialized. This is a singleton, so he is lazy .
Basically, your question is the same as val and the object inside the Scala class , except that your val and object defined in object , but the related question tries to find the differences between val and object defined in the class , and the method in val uses reflection ( but yours uses redefinition, therefore reflection is not involved). implicit basically does not affect what they are.
I think you already know the difference between class and object . Further information can be found in the related question.