Brad wrote: > Gennady wrote: > > > > > 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 > > > > > > > > > > True, in the case you present I would not expect a and b to be altered. > But what I was wondering was if there were some way to allow > manipulation of Sorry didn't mean to send that one. :) Hit wrong key sequence. What I was trying to say was... I was wondering if there were some way to allow manipulations of function/methods parameters such that the calling processes variable values would be modified. As I understand it now this is not possible, though being new to Ruby I thought it couldn't hurt to ask. Thanks for your response. Regards, Brad