in reply to Re: swapping vars, two ways, 2 results...
in thread swapping vars, two ways, 2 results...

but why is it that much faster ?
  • Comment on Re: Re: swapping vars, two ways, 2 results...

Replies are listed 'Best First'.
Re: Re: Re: swapping vars, two ways, 2 results...
by BrowserUk (Patriarch) on Dec 18, 2002 at 23:08 UTC

    This ($a,$b) = ($b,$a); is notionally equivalent to

    { local @list; $list[0]=$b; $list[1]=$a; $a=$list[0]; $b=$list[1]; undef @list; }

    Instead of allocating one temprary scalar and doing 3 assignments, it is allocating a temporary list, performing 4 assignments and deallocating the list.


    Examine what is said, not who speaks.