I am writing a recursive function
Can we use a case classs 'A' inside of the same case class 'A'
Ex:
case class FramesFolderData(key: String, title: String, parentId: Long, children: Option[List[FramesFolderData]])
I am writing a recursive function
Can we use a case classs 'A' inside of the same case class 'A'
Ex:
case class FramesFolderData(key: String, title: String, parentId: Long, children: Option[List[FramesFolderData]])
Yes, this is valid Scala and is a good way to define a recursive data structure.
I would recommend removing the Option in the children field. You can indicate "no children" with an empty list (Nil) so there is probably no need to use an Option as well.