Making a component which can output a single item or a list

Hi all,

I am just wondering if there is a way to create a custom component which can output either a single item or a list? For example, depending on the input, if it is an instance of class A, create a single item, otherwise create a list of items.

Many thanks,
Nicholas

The access of a parameter needs to be known before the solution starts. So you cannot decide inside SolveInstance whether you want to output a list or an item. You can change the access outside of solutions, and indeed there’s a few components which do this, depending on menu options.

What you can do is set the output access to List or Tree, and only assign a single value.

Thank you David. We decided to output a list even if it is just a single item.