i have case class:
case class c(a:string, b:string, c:int, d:long, e:string ... )   i want join members in class
val c = new c("a", "b", 1,  1l, "e" ... )  val joined_str = c.a + c.b + c.c + c.d + c.e ...  // many members...   is there function join members easily? don't want write many member names, because number of members many , name of members long...
the short answer,
val c = c("a", "b", 1,  1l, "e") c.productiterator.mkstring(",") res0: string = a,b,1,1,e   case classes equipped product iterator iterating on fields.
note though looses type information; instance,
c.productiterator.toarray res1: array[any] = array(a, b, 1, 1, e)   becomes array of any.
Comments
Post a Comment