From: Matthew Kerwin Date: 2013-07-09T08:14:41+09:00 Subject: Re: A very half-baked idea: setting local variables Hal Fulton wrote in post #1114777: > > Note that this wouldn't be a method call (like alias_method) but > a keyword (like alias) unless "binding of caller" was permitted... > which is another thing I've wanted but I suppose will never > happen. > > Comments, questions, projectiles? > Yeah, I agree with Robert, there's no need to dynamically create local variables, just use a hash (dynamically created keys are fine). And my initial gut response is: if you're writing that many variables on the left hand side of an assignment, with a single array on the right, there's probably something wrong with the architecture. My other counter-proposal is: hit enter. If the line is too long, develop a syntactic signature for the pattern. For example: foo, bar, baz, alpha, beta, gamma, fred, bill, joey = *values (i.e. lining up the rightmost column, so it's clear that all wrapped lines lead to the single assignment operator). Still not great, but at least the line isn't absurdly long, and you don't have to scan as far to see the '=' Finally, as a bike-shedding nit-pick: if it were a keyword, convention suggests there'd be no comma; and I think putting the destinations on the right is a bit confusing. So if I had to choose, I'd go for: assign %I[a b c] values But again, that's a big "if", and all in all I'm not too keen on the idea of dynamically creating local variables. -- Posted via http://www.ruby-forum.com/.