Is there any difference between the following:
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a.replace(z)
and
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a = z
They seem to do the same thing.
Thanks!
Todd B.
Is there any difference between the following:
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a.replace(z)
and
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a = z
They seem to do the same thing.
Thanks!
Todd B.
On Fri, Jun 09, 2006 at 02:54:32AM +0900, Todd B. wrote:
Is there any difference between the following:
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a.replace(z)
a.object_id == z.object_id
and
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a = z
a.object_id == z.object_id
marcel
On 6/8/06, Marcel Molina Jr. [email protected] wrote:
and
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
z = [‘x’,‘y’,‘z’]
a = za.object_id == z.object_id
=> true
Also:
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
b = a
z = [‘x’,‘y’,‘z’]
a.replace(z)
p b # => [‘x’, ‘y’, ‘z’]
vs.
a = [‘a’,‘b’,‘c’,‘d’,‘e’]
b = a
z = [‘x’,‘y’,‘z’]
a = z
p b # => [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
Jacob F.
On 6/8/06, Jacob F. [email protected] wrote:
z = [‘x’,‘y’,‘z’]
a = z
p b # => [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]Jacob F.
OK. I get it. When I use the assignment, a becomes (points to the same
object as) z. Using replace, both maintain their individuality.
Thanks for the clarification.
Todd
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs