From: Mohammad Khan Date: 2005-01-20T03:13:21+09:00 Subject: Re: value by reference On Wed, 2005-01-19 at 12:54, Austin Ziegler wrote: > On Thu, 20 Jan 2005 02:17:19 +0900, Mohammad Khan wrote: > >> a, b, and c are not objects. They're variables. > > Isn't everything *object* in Ruby? > > Now you know, what I am after ?! > > Yes, and no. > > a = 1 > b = 2 > c = 3 It would be great if we can do a = Integer.new(1) b = Integer.new(2) c = Integer.new(3) and we can pass object a, b, c rather than variable a, b, c. Thanks Austin and Florian for explaining variables and object. -- MOhammad > > The values 1, 2, and 3 are objects. a, b, and c are not objects. > > def foo(a, b, c) > end > > In #foo, a, b, and c are most definitely NOT objects -- they're > variables that (will) contain references to objects. > > In Ruby, variables are names, not memory slots. > > a = b = 1 > > The real memory slot is more or less identified by Object#id. The > variable is just a convenience label for that object. Change the > object that the label is pointing to, and you just change the > position of the label's name. You're not actually changing the > memory location involved. > > What you're after is something you shouldn't do with Ruby. Rethink > your design. > > -austin