I don't understand how to manipulate Trees and Forrests.. can someone explain?

17 views
Skip to first unread message

Jon Ross

unread,
Jun 29, 2018, 7:34:32 PM6/29/18
to treehugger-scala


I do stuff like map some xml and get a list of generated case classes. So all good. But then I want to insert them into a PACKAGE, and I can't because I have a List[treehugger.forest.ClassDef] and it wants a tree. How to I coerce a list of trees into a tree?

Along the same lines, sometimes I'm working in a BLOCK() and I want to added a function only if a field is present in the XML. example :

BLOCK(
 PROC(something.name) ....
 if(something.speical.isDefined) PROC(something.special.name) ....
)

where "something" is a bunch of case classes that were populated from some xml document.

There doesn't seem to be a way to optional put something into a BLOCK.

I'm sure that's not the case, I'm sure that it's that I don't understand how trees/forests work and how to manipulate them in a non-static fashion .

All the documentation (which is great BTW) is all static creation of stuff, AFAICT

Sorry in advance if this is a really stupid question.

-Jon

Reply all
Reply to author
Forward
0 new messages