2021年3月17日星期三

Scala - how do define a case class dynamically

Scala version - 2.11

Ex: case class header(name:String, version:String)

I want to define a configurable case class.

Approach 1: --didn't work

val columnList = "name:String,version:String"  case class header(columnList)  

Approach 2: dynamically create case class on runtime.

How would I go on about doing that? I want to read a list of columns from .config file and be able to represent a case class with the n # of columns.

Any other approaches would be helpful? Thanks.

https://stackoverflow.com/questions/66681149/scala-how-do-define-a-case-class-dynamically March 18, 2021 at 05:00AM

没有评论:

发表评论