From: Gennady Date: 2003-12-12T07:50:04+09:00 Subject: Re: Simple issue giving problems On Dec 11, 2003, at 14:37, Brad wrote: > Hello all, > > I have a problem that may or may not be an easy fix. :) > > Given the following: > > > a=1 > b=2 > > def swapper(dest,src) > dest,src=src,dest > end If you put it this way: a=1 b=2 dest=a src=b dest,src=src,dest It swaps dest and src. And I do not think you would expect a and b being swapped as well as a result of this. Same with calling a method as in your example. You cannot deal with variables' addresses in Ruby as in C. > > swapper(a,b) > p [ a, b ] > > > > Why are the values of the variables not swapped? Is there > a way to coerce ruby into doing a and b by using src and dest? > > Any help is greatly appreciated. > > Thanks, > > Brad > > Sincerely, Gennady Bystritsky