From: Josh Cheek Date: 2010-04-03T00:43:57+09:00 Subject: Re: scope question --000325563362e154b2048342d812 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2010/4/2 Jes=FAs Gabriel y Gal=E1n > So my point is that, independently on the internal implementation of > Fixnums, the important consideration for his question is the fact that > they are inmutable, and so it's impossible to call a method that would > modify the object. So it's not possible to mimic the same examples as > with hashes and arrays. > > Jesus. > > You can get the array and hash to mimic the number, though, by calling non mutating methods on them. def scope( old_hash , old_array , old_num ) puts "in scope" p (old_hash.merge Hash[ 'e',5 , 'f',6 , 'g',7 ]) # =3D> {"a"=3D>1, "b"= =3D>2, "c"=3D>3, "d"=3D>4, "e"=3D>5, "f"=3D>6, "g"=3D>7} p (old_array +=3D [5,6,7]) # =3D> [1, 2, 3, 4, 5= , 6, 7] p (old_num +=3D 1) # =3D> 8 end hash =3D {"a"=3D>1,"b"=3D>2,"c"=3D>3,"d"=3D>4} array =3D [1,2,3,4] num =3D 7 scope( hash , array , num ) puts puts "after scope" p hash # =3D> {"a"=3D>1, "b"=3D>2, "c"=3D>3, "d"=3D>4} p array # =3D> [1, 2, 3, 4] p num # =3D> 7 --000325563362e154b2048342d812--