From: Csaba Henk Date: 2005-03-23T12:14:49+09:00 Subject: Re: RCR 296: Destructive methods return self So the point is that we should not create a situation in which it easily happens that the designer of a class forces an interface on the user. On 2005-03-23, Daniel Amelang wrote: > Sure, multiple return values are only accessable in an assignment > (rvalue). Otherwise, you only get the first value. This is bad in the above respect: either the class designer forces using assignment on its users when they don't want to lose information, or he/she has to take extra care to define alternative interfaces (eg., a method which does the same except that it returns an array). > Or, consider this: you could tack a * on the front if you wanted to > trap them in an array. That should cover your bases: > > (*get_mult_values).each {|value| ...} > > Seems pretty simple. What do you think? I may have missed some use case... This second one sounds better, but not perfect. "*" is used now in the opposite sense: not for returning some stuff bundled in an array, rather for "inlining" the content of the array. So with this proposal you should write: arr.values_at **get_mult_values which is ugly. Of course, if we introduced multiple values, as an accompanying enhancement, we should also introduce that automatically all values are retrieved if you use the method as a tail of a parameter list of a method call which takes undefinite number of arguments. So then you could write just arr.values_at get_mult_values However, this doesn't hide the twist that "*" is used in the opposite sense. But I could live with it, and rather overload "*" in this way than to introduce one more punctuation symbol for uniqueness. Or, maybe "*" could be explicitly turned to such an operator which toggles bundling/inlining. So the following would be valid: **[1,2] == [1,2] Not as if it were useful as such, but then "*" would still have a consistent meaning. Up till now (and now) it wasn't an issue as "bundling" was not present in ruby. But with multiple return values, it would appear on the scene and should be handled properly. Csaba