Re: Multi-assign
- Posted by BRyan Nov 15, 2011
- 2722 views
mattlewis said...
For 4.1, I started working on multiple assignment. Basically, it would look like this:
{ x, y } = { 1, "foo" } { $, x } = value( y )
It's really syntactic sugar, but can make some code a lot easier to read. My implementation currently uses dollar signs to ignore values. There's been some concern on the dev list that this might be confusing, so I'd like to get feedback from the wider community.
Does a dollar make sense? Should we use a different symbol? Should we just put extra commas in?
For those interested, the code is currently in the 'multi-assign' branch in the Mercurial repo.
Matt
I don't really understand what multiple assignment is; but if you use a dollar sign in a sequence could it be confused with the last position of a sequence for example: seq[1..$]