It could just be my own aesthetics, but I would think that if it is "sloppy" in one usage than it is also in the other?
While I like the paren-less tuple destructuring, I'm more concerned with consistency and predictability, and I found this behavior surprising. As you say though, Jeff may have a reason. -s On Sun, Jan 5, 2014 at 7:06 PM, Stefan Karpinski <[email protected]>wrote: > I have often wanted this but it is a bit "sloppy". Jeff may have a reason > for not allowing this. > > > On Sun, Jan 5, 2014 at 9:57 PM, Spencer Russell <[email protected]> wrote: > >> When a function returns a tuple, you can omit the parentheses from the >> target variables, like: >> >> a, b = foo() >> >> instead of >> >> (a, b) = foo() >> >> But it seems you can't when setting up a for loop: >> >> for i, x in enumerate(all_my_foos) >> # do something >> end >> # throws an "syntax: invalid iteration specification" >> >> But it works if I put parens around "i, x". Is this intentional? It's not >> a big deal to put the parens, but it did trip me up a bit as I expected the >> same behavior as normal function application, and coming from Python I'm >> very used to using enumerate in this way. >> >> -s >> > >
