scala-hamsters / hamsters

A mini Scala utility library
Apache License 2.0
291 stars 23 forks source link

Write def (macro?) for Show #100

Open loicdescotte opened 6 years ago

loicdescotte commented 6 years ago

Recurring demand from a few number of users

loicdescotte commented 6 years ago

With Scala 2.13 it will be possible to do it without macro with something like :

  def show(p: Product): String =
    p.productElementNames.zip(p.productIterator)
     .map { case (name, value) => s"$name=$value" }
     .mkString(p.productPrefix + "(", ", ", ")")
loicdescotte commented 6 years ago

pushed #117 PR with macro-free show method on case classes