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
>

Reply via email to