Using shapeless scala to merge the fields of two different case classes
问题 I want to merge the fields of two different case classes into a single case class. For example, if I have the following case classes: case class Test(name:String, questions:List[Question], date:DateTime) case class Answer(answers:List[Answers]) I want a concise shapeless way to merge both into: TestWithAnswers(name:String, questions:List[Question], date:DateTime, answers:List[Answer]). Is there a nice shapeless answer out there? 回答1: You can use shapeless Generic to do this. val t: Test = ???