3 ms·
You could create an abstract class for the base response, then implement this abstract class for the two cases one where it has a list member, and one where it
by okamiueru 6y ago
You could create an abstract class for the base response, then implement this abstract class for the two cases one where it has a list member, and one where it contains the object. Then, using the return value with something like `if (response is listLike) { }` the IDE already knows that you are scoped to having only the list like properties, and you'd get the full help of the language. Something like that, I suppose.
- oblio 6y agoVersus a sort of: my_type = my_list | my_object ? You can see why this is better :-)
- okamiueru 6y agoAll I can say is that it is certainly neat :)
- mixmastamyk 6y agoI'd always return a list. Makes the client code simpler.
- oblio 6y agoYou would. But not every input comes from you :-)