From: Ralph Mason Date: 2001-12-06T13:47:45+09:00 Subject: [ruby-talk:27598] References This is a multi-part message in MIME format. ------=_NextPart_000_0098_01C17E31.F68A4A80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Perhaps I am just being greedy here. But it is something that in some = cases makes your code clearer In C++ I can write void normalise( var& x, var& y ) { if (x > y ) swap ( x,y); } and effect the actual variables that are passed in. eg normalise(x,y) //x and y are effected In ruby I have x,y =3D normalise(x,y) or in this case x,y =3D [y,x].sort But it just doesn't feel as nice. I know I could do something with proxying ect, but then there is allot = unneeded overhead in that. If variable were a class then references = would not be too much of a problem. a ruby solution could be normalise( &x , &y ) # the & returns an instance of the variable class def normalise!( x, y ) //here you get instances of var (the one and only variable class) x,y =3D [y,x].sort end Perhaps having variables as a class would have some other uses also? Or is there some nice way to do this that I have missed? Thanks, Ralph ------=_NextPart_000_0098_01C17E31.F68A4A80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Perhaps I am just being greedy = here.  But it=20 is something that in some cases makes your code clearer
 
In C++ I can write
 
void normalise( var& x, var& y=20 )
{
    if (x > y ) swap ( x,y);
}
 
and effect the actual variables that = are passed=20 in.
 
eg
 
normalise(x,y) //x and y are = effected
 
In ruby I have
 
x,y =3D normalise(x,y)
 
or in this case
 
x,y =3D [y,x].sort
 
But it just doesn't feel as = nice.
 
I know I could do something with = proxying ect, but=20 then there is allot unneeded overhead in that.  If variable were a = class=20 then references would not be too much of a problem.
 
a ruby solution could be
 
normalise( &x , &y ) # the = & returns an=20 instance of the variable class
 
def normalise!( x, y )
    //here you get = instances of var=20 (the one and only variable class)
    x,y =3D = [y,x].sort
end
 
 
Perhaps having variables as a class = would have some=20 other uses also?
 
Or is there some nice way to do this = that I have=20 missed?
 
Thanks,
Ralph
 
------=_NextPart_000_0098_01C17E31.F68A4A80--