On Tue, Feb 15, 2011 at 6:39 PM, Matt Baluyos <[email protected]> wrote: > Hmm... Interesting subject (and we've haven't anything interesting in > this list for a while, LOL).
indeed, parallel assignment isn't a basic feature :) > It's a cool feature, but any developer who uses this feature on a > real-world project will probably get an earful from me for sacrificing > maintainability/readability for the sake of coolness. I can only > imagine how many keystrokes you'd waste trying to edit a variable > that's in the middle of an enumerated list - not too mention the bugs > you might introduce because you missed which variable is on which > value (Nalibat ug tan-aw bah, LOL) the emphasis should be on the *assignment* ;ie, the lvalues being individually mapped from a supposed array/collection-like list.. another example, if i may: let's say i have an array a a=["botp", "x", "1000", "1000", "botp,,,", "/disk2_2/home/botp", "/bin/bash"] and i want to assign the 1st element to name, 3rd elem to userid, 2nd-to-last-element to home, and last element to shell then using parallel assignment, just do name, _, userid, *_ , home, shell = a instead of the usual name = a[0] userid = a[2] home = a[-2] shell = a[-1] note here i'm already using the negative indexes feature to access elements from behind > On a similar note, I do lurv using the ternary operator in PHP [1] - > but that's because I'm too lazy to write a whole if-else block when I > can do it with one line. It also makes me look cool sa mga newbies. i think ternary op was popularized by C. i use them, but i don't nest them, otherwise i'd use the block mode (yes, paranoid and not cool of me :-) best regards -botp _________________________________________________ Kagay-Anon Linux Users' Group (KLUG) Mailing List [email protected] (http://lists.linux.org.ph/mailman/listinfo/klug) Searchable Archives: http://archives.free.net.ph
