develooper Front page | perl.perl6.language | Postings from April 2001

Re: Larry's Apocalypse 1

Thread Previous | Thread Next
From:
Richard Proctor
Date:
April 6, 2001 14:07
Subject:
Re: Larry's Apocalypse 1
Message ID:
Marcel-1.53-0406210117-d07Rr9i@waveney.demon.co.uk
On Fri 06 Apr, John Porter wrote:
> Richard Proctor wrote:
> > but what should 
> >       @bar = @foo x 2;
> > do?  Repeat @foo twice or repeat each element twice?  (its current
> > behaviour is less than useless, other than for JAPHs)
> 
> How is one significantly less useful than the other?
> 

Its current behaviour is to assign to $bar[0] the length of @foo repeated
twice.

  DB<1> @foo = (1,2,3)

  DB<2> @bar = @foo x 2

  DB<3> p "@bar"
33
  DB<4> p $bar[0]
33

This is what I call less than useless, perhaps you are thinking of,
the current behavior of @bar = (@foo) x 2

  DB<5> @bar = (@foo) x 2

  DB<6> p "@bar"
1 2 3 1 2 3

Which has real application.

Richard
-- 

Richard@waveney.org


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About