From: Jamal Soueidan Date: 2007-04-06T22:24:58+09:00 Subject: Re: Everything is a object? Gary Wright wrote: > On Apr 4, 2007, at 2:49 PM, Jamal Soueidan wrote: Thanks for your comment, now I understand that all the unused instance variable would reference to the same object until they come into existence: 1. by assigement. 2. by reference (as default to nil object) 3. by using the object method instance_variable_set() Brian Candler wrote: > On Thu, Apr 05, 2007 at 03:49:15AM +0900, Jamal Soueidan wrote: > puts does an implicit to_s on anything you pass to it, so you don't actually > need to do that explicitly. Thanks, now I know :) >> puts @myvar="string".class.to_s >> # String > > Careful here. This is the same as > > puts @myvar=("string".class.to_s) True, puts "string".class ----------------------------------------- Thanks for the other replies :D Now the question is, When does the instance variable holds the object itself? class A; end; @one = A.new @two = A.new p @one.object_id p @one_object_id # 21103660 # 21103640 Two different objects, even if they were the same. How does all the nil instance variable reference to the same object? -- Posted via http://www.ruby-forum.com/.