3 ms·
Surely the "clean" way to return multiple values from a function is to support returning a tuple. The methods positional parameters already essentially constitu
by willtim 9y ago
Surely the "clean" way to return multiple values from a function is to support returning a tuple. The methods positional parameters already essentially constitute a tuple argument.
Such structural grouping of values however went against OOP dogma at the time, which dictated that every type must have a name. Even after generics were introduced into Java, Sun refused to add even a pair class to the JDK (IMHO the bug report was amusing reading). Perhaps they were also similarly opposed to C#'s features?
- Sylos 9y agoThe "out" feature definitely violates OOP principles even more than tuples would. You're passing along a variable which is then overwritten in the method to serve as a return value. Essentially just a somewhat formalized use of side effects.