From: Florian Gross Date: 2005-03-24T11:04:58+09:00 Subject: Re: RCR 296: Destructive methods return self Trans wrote: >>Let's keep talk about this for a moment. >> >>We'll finally get keyword arguments in Rite and they're already in Ruby >>1.9 as well. >> >>But what about keyword return values? How would those look? >>[...] >>Perhaps (result: a, changed: b) = obj.strip! would work. >> >>I think the case of (result: result, changed: changed) would be quite >>common so perhaps it would be a good idea to introduce a short-cut. >>Maybe (:result, :changed) = rhs. > > I'm not sure I understand your short-cut. What variables would the > results end up in? result and changed. It assigns the keyword return value with that name to the variable with that name. It might be very rarely needed, though. I think the uncompressed syntax would be more useful. > return ( arg1: value1, arg2: value2 ) > > Perhaps? Then how does one capture these values, which is what you're > asking. Yes? Is the return value a hash now as opposed to an array? Or > is it something different entirely? That looks nice. I think it would return a Hash. My suggestion for capturing them is to introduce a new variable assignment syntax: (x: var1, y: var2) = {x: 1, y: 2} var1 # => 1 var2 # => 2 This might look odd at first, but I think it makes some kind of sense...