Re: Multi-assign

new topic     » goto parent     » topic index » view thread      » older message » newer message
BRyan said...

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..$]

Multiple assignment is a way to take the result of an expression that is a sequence, probably most commonly the return value of a sequence, and assign it in one go, without having to use a temporary variable. So:

-- instead of: 
x = value( something ) 
my_number = x[2] 
 
-- you could do: 
{ $, my_number } = value( something ) 

The confusion was the argument brought up, but I'm honestly not sure how one would confuse this. Also, $ can already be used as a list terminator:

constant 
    A = 1, 
    B = 2, 
    $ 
 
sequence s = { 1, 2, 3, $ } 

So, it's basically a place holder. Personally, I like it better than something like an underscore or a dash or a dot because as a glyph, it's fairly substantial and easy to spot and differentiate from other things.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu