New nodes using variable

I have an abstract concept and few subconcepts that extend it. I created a node factory that creates one instance of each subconcept when new root node is created. Everything works when I specify subconcepts directly:

But when I want to create instances using a cycle through all subconcepts, add new() method is not accepting any parameter or expression. I expected the code to look like this, but this is not valid:

Thanks.
Tomas

2 comments
Comment actions Permalink

Expressions cannot be used as parameters to "add new". You'll have to use "add()" instead:

newNode.subObjects.add(it.new instance())

 

1
Comment actions Permalink

Vaclav, thanks very much, works nicely. Tomas

1

Please sign in to leave a comment.