Skip to content

Instantly share code, notes, and snippets.

@kindlychung
Created December 23, 2016 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kindlychung/abbc96e9d4d3df05dc78b3d9ab12d060 to your computer and use it in GitHub Desktop.
Save kindlychung/abbc96e9d4d3df05dc78b3d9ab12d060 to your computer and use it in GitHub Desktop.
case class User(name: String, age: Int)
object User {
implicit val userPrinter: InfoPrinter[User] = new InfoPrinter[User] {
override def toInfo(value: User) = s"[User] name: ${value.name}, age: ${value.age}"
}
}
val userInfo = implicitly[InfoPrinter[User]].toInfo(User("Xiaohong", 24))
println(userInfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment