4 ms·
> have you worked with java or C#? both are where types sometimes become a burden. > No, you cannot just do something like this: > ``` return { data, message:
by AdieuToLogic 2y ago
> have you worked with java or C#? both are where types sometimes become a burden.
> No, you cannot just do something like this:
> ``` return { data, message: "OK" }; ```
Yes, in Java you can:
return new Object() {
String message = "OK";
Object data = itsValue;
};
There are many reasons to dislike Java and it is nowhere near my programming language of choice. The specific semantic deficiency you chose happens to be an invalid one.
- dasyatidprime 2y agoAnd how does the caller extract those fields?
- AdieuToLogic 2y ago> And how does the caller extract those fields? The same way one would when returning an anonymous map in JavaScript - via reflection and the assumption of what was returned. While JavaScript makes the use of reflection less burdensome, it has the same collaboration fragility as a Java version. Just with less ceremony.