Case class to map in Scala
Is there a nice way I can convert a Scala case class instance, e.g. case class MyClass(param1: String, param2: String) val x = MyClass("hello", "world") into a mapping of some kind, e.g. getCCParams(x) returns "param1" -> "hello", "param2" -> "world" Which works for any case class, not just predefined ones. I've found you can pull the case class name out by writing a method that interrogates the underlying Product class, e.g. def getCCName(caseobj: Product) = caseobj.productPrefix getCCName(x) returns "MyClass" So I'm looking for a similar solution but for the case class fields. I'd imagine a