News for hackers. Stuff that matters.
Re:Flutter 2 by okamiueru on Wednesday March 03, 2021 @04:14PM (#26334639)
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.
Re:Flutter 2 by oblio on Wednesday March 03, 2021 @04:49PM (#26335144)
Versus a sort of:

my_type = my_list | my_object

?

You can see why this is better :-)

Re:Flutter 2 by mixmastamyk on Thursday March 04, 2021 @12:31AM (#26339007)
I'd always return a list. Makes the client code simpler.
Re:Flutter 2 by oblio on Thursday March 04, 2021 @01:16AM (#26339234)
You would. But not every input comes from you :-)
Re:Flutter 2 by okamiueru on Wednesday March 03, 2021 @05:22PM (#26335584)
All I can say is that it is certainly neat :)