From: Justin Collins Date: 2005-12-15T05:28:16+09:00 Subject: Re: Concerning the #to_* convention Daniel Schierbeck wrote: > ts wrote: >>>>>>> "D" == Daniel Schierbeck writes: >> >> D> I hope you can give me a hint of what the best practice is. >> >> I don't know what is the best practice but you can ask ruby >> >> moulon% ruby -e 'a = [1, 2]; b = a.to_a; p a.object_id==b.object_id' >> true >> moulon% >> moulon% ruby -e 'a = "12"; b = a.to_s; p a.object_id==b.object_id' >> true >> moulon% >> >> >> Guy Decoux > > Sweet! Thanks! > > > Cheers, > Daniel > Those two examples are returning the same object because it is already in the desired form. If it is actually a change, you will get a new object: irb(main):001:0> a = 12 => 12 irb(main):002:0> b = a.to_s => "12" irb(main):003:0> a.object_id => 25 irb(main):004:0> b.object_id => -605442624 -Justin