Re: 3.0.2 BUG! ( maybee)

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

Hayden McKay wrote:
> 
> I don't know if this one has been posted before...
> }}}
<eucode>
> sequence a,b,c,d
> 
> a = {} b = {} c = {} d = {}
> 
> a &= {}   b = append(b, {})  -- a = {}  b = {{}}
> c &= 1    d = append(d, 1 )  -- c = {1} d = {1}
> </eucode>
{{{

> 
> Whats wrong with 'a' ?

This is how I remember the difference between &= and append() ...

'&=' adds every element in the source to the target sequence. The length of the
target sequence is increased by the length of the parameter.

'append()' adds the source as a single element to the target sequence. The
length of the target sequence is increased by 1.

Thus 

  a &= {}  

gives every element of {} (i.e. none) is added to a. length(a) is increased by
zero.

  b = append(b, {})

gives the source (an empty sequence) is added to b. length(b) is increased by 1.

To get the same effect as append() when using '&=', wrap the source in '{}'.
Thus

   a &= {{}} 

is the same as 

   a = append(a, {})




-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu