On Tue, Jan 11, 2011 at 7:54 PM, Kedar Mhaswade <kedar.mhaswade / gmail.com> wrote: > Robert Klemme wrote in post #973945: >> On Tue, Jan 11, 2011 at 3:29 PM, Kedar Mhaswade >> <kedar.mhaswade / gmail.com> wrote: >>> >> > https://docs1.google.com/document/d/1zpHvfO4be3UvjaxU7L5gEPXFMENcMmEz9qqIcecEzOg/edit?hl=en# >>> >>> Summary is, I should only spend time learning >>> - x, y, z = 1, 2, 3 (# => x=1, y=1, z=3), and >>> - x, y = y, x (# => swap x and y) >>> >>> I gather that this might be a matter of taste and style, but are other >>> variants used by community? >> >> Just today I used >> >> def []=(*idx, val) >> index_check(idx) >> @data[idx] = val >> end >> >> https://gist.github.com/772827 >> >> See also thread "Nooby question : multidimensional arrays.". >> >> I find the pattern matching _very_ elegant. ¨Âèéáìóï ãïíåéî èáîä>> in situations like this: > > Maybe I am not understanding it, but I thought that elegance is because > of splat operator (which I am sure I like). The splat operator is just part of the game as Josh has tried to demonstrate. The real power comes from pattern matching which will even work with multiple levels of nesting. And the mechanism is the same for method and block arguments which gives you one powerful mechanism usable in several places. > My gripe is about various > forms of parallel assignment and semantic/syntactic complexity because > of that. Or are you saying that once you say you need splat operator, > all this complexity is inevitable (of course, I can work around it by > not using it, but then how do you all use it?) No, I am saying that parallel assignment is just a special case of the assignment mechanism that is also in effect for method and block arguments. And while I don't use the fancy variants often (as Josh) when I use it it yields an elegant solution that would be more cumbersome without it. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/